Tech Industry
Yesterday
1413
Netflix vs Quant vs Meta
2024 Presidential Election
Yesterday
542
Heartwarming peaceful protests
India
Yesterday
553
Who are these retards asking for dictatorship in India?
Tech Industry
Yesterday
3551
Asians - what are your thoughts on asian female white male ?
India
Yesterday
447
Modi is a legend, will be remembered for centuries to come
Learning system design and wanted to know if it's a good idea to have two micro services being able to touch a database. Or does one service own the database? And other services need to ask that service for data?
In general, 2 different micro services shouldn’t directly touch the same DB
What’s important is that you identify and talk about potential issues and benefits with this approach. In real world, for a small company(low qps) it makes sense to go with single db while you use the acid properties to maintain data consistency. Shit breaks when you reach higher qps. Your writes and reads will slow down. One service will be seeing delayed responses due to issues in other service/services. Again, do not go with what I said about this approach being ok for low qps. Shows that you are not able to think through the issue. Best is, never answer these kinda scenarios with single statement answers. Always try to dig deeper or talk about different approaches. Ofcourse you will not have time to go through everything. But it is what it is. More experienced folks are able to clearly communicate more in a short amount of time. Which is why Sys design is a good indicator for the eng leveling.
You should next ask whether micro services are ever a good idea :) The upside of separate services is the ability to deploy, test, and scale independently. And to a lesser extent enforcing firm interfaces between components. The downside is additional complexity and overhead. If two services depend on the same database, you don’t get the upsides, but you get the downsides. So usually there would be no good reason to separate them. The complexity costs of micro services should not be underestimated. They make it significantly harder and slower to debug your system compared to running code in the same program.
This question has found to lack context. The type of database, if you are touching the same tables. I imagine multiple microservices could write to a cache database or a blobstore. Let’s say you have different tables, you could have a service that works completely around authenticating users and it only touches user tables while another service handles other request that user has made?
If you design website like Amazon, only one micro service touches database?
I'm confused