Elasticsearch in microservices architecture Elasticsearch in microservices architecture elasticsearch elasticsearch

Elasticsearch in microservices architecture


Even if you were using a relational database, there are approaches to achieve persisted data encapsulation other than provisioning separate databases instances for every service. Having a separate schema for each is one alternative that can still keep your architecture "nice and shiny". So are privately owned tables. As long as you follow the intent to keep things separated without any cross-domain dependencies or constraints while putting up some barrier to prevent other microservice teams from cheating, you're still on the shiny side.

That all goes for Elasticsearch too. I'd take advantage of its multitenancy capabilities and just use indexes to split ownership. That should be clean and easy considering you only have two users (microservices). You could consider adding the Elasticsearch Shield plugin for role-based index ownership to prevent cheating by other teams for a really shiny solution. With Elasticsearch this gets really flexible because you can tailor the indexes to the load and data volume for each microservice.

Since you can get the degree of encapsulation required plus you have service-specific configuration (via the indexes), in my opinion your second option is OK since it still conforms to the intent of the architecture.