3 ms·
How do you deal with cache invalidation? That seems like a potential major security risk. Caching other microservice's data in general just sounds like a bad i
by debaserab2 10y ago
How do you deal with cache invalidation? That seems like a potential major security risk.
Caching other microservice's data in general just sounds like a bad idea.
- virmundi 10y agoIn the examples above, the primary source of truth is the auth service. However, the rights get distributed (duplicated) to the various services. As I pointed out towards the end, there is a period of time where the auth service might say that a user lacks a group, but that the recipe service says the user has the group. During this window of time, the system will allow the user to access a feature that requires the group they are in fact no longer a part of. The same is true if you put groups in a JWT. Caching is caching. You always have to weigh the benefits against the cons. In general this is a problem with distributed systems. CAP and all that. What do you do if your network is partitioned such that the recipes service can service requests while the auth service can't notify the recipe service of changes? You can bring the whole system down. You can continue to allow operations based on the cached rights. You could limit operations if you haven't gotten a heart beat from the auth service in while. Back to the example, say group changes occur rarely. Say over that, network partitions (including message system failures) occur rarely too. Chances of both happing is P(partition, msg_failure). Probably small chance. If you can live with that, you're life might be better. If you have hard requirements to always get the auth, you might need to couple. Even then you're not really guaranteed that the latest data from the auth service is the latest data concurrently. Finally, even if you have coupling, you can still design the system to use profiles to pick the service. When you're running locally, don' go to the real auth system, just go to SimpleHTTPServer. Don't attempt to run the auth service locally. SimpleHTTPServer will probably use fewer resources than your micro service using some complex library.