Using separate read and write databases offers a range of benefits:
- Better performance
- Increased scalability
- Fault tolerance
Let's break them down.
𝗕𝗲𝘁𝘁𝗲𝗿 𝗽𝗲𝗿𝗳𝗼𝗿𝗺𝗮𝗻𝗰𝗲
By separating reads from writes, you can tune each database for its specific purpose.
𝗜𝗻𝗰𝗿𝗲𝗮𝘀𝗲𝗱 𝘀𝗰𝗮𝗹𝗮𝗯𝗶𝗹𝗶𝘁𝘆
You can scale each database independently when using separate read and write databases. This is particularly useful when your application's queries lean heavily to one side.
HttpClient is an excellent abstraction and incredibly easy to work with.
Unfortunately, it's also easy to misuse, leading to problems like port exhaustion.
You need to know how NOT to use it.
If you think IHttpClientFactory will solve all your problems, you're only partly right.
Should you use named clients or typed clients?
Microsoft was kind enough to provide us with a set of best practices and recommended use for HttpClient.
- Use a static or singleton HttpClient instance with a PooledConnectionLifetime configured since this solves both port exhaustion and tracking DNS changes
A class should have only one reason to change. In other words, a class should have a single, well-defined responsibility. That class should entirely encapsulate responsibility.