Summary

In this chapter, we've covered a lot to do with databases. We started by creating a plain connection to PostgreSQL. After that, we added a pool of connections with the r2d2 crate and used the rayon crate to execute SQL statements in parallel. We created a tool to manage our users database, and reimplemented it for our MySQL database.

We have also mastered some ways of interacting with NoSQL databases, in particular, Redis and MongoDB.

The last database we explored was DynamoDB, which is part of Amazon Web Services and can be scaled very easily.

For all examples, we run database instances in containers, because it's the simplest way to test interactions with databases. We haven't use database connections in microservices yet, because it requires a separate thread to avoid blocking. We will learn how to use background tasks with asynchronous code later, in Chapter 10Background Tasks and Thread Pools in Microservices.

In the next chapter, we will explore a different approach to using databases—object-relational mapping with the diesel crate.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.119.170