Microservices Architecture: Cross Service data sharing -



Microservices Architecture: Cross Service data sharing -

consider next micro services online store project: users service keeps business relationship info store's users (including first name, lastly name, email address, etc')

purchase service keeps track of details user's purchases.

each service provides ui viewing , managing it's relevant entities. purchase service index page lists purchases. each purchase item should have next fields: id, total name of purchasing user, purchased item title , price. furthermore, part of index page, i'd have search box allow store manager search purchases purchasing user name.

it not clear me how info purchase service not hold - example: user's total name. problem gets worse when trying more complicated things search purchases purchasing user name.

i figured can solve syncing users between 2 services broadcasting sort of event on user creation (and saving relevant user properties on purchase service end). that's far ideal in perspective. how deal when have millions of users? create millions of records in each service consumes users data?

another obvious alternative exposing api @ users service end brings user details based on given ids. means every page load in purchase service, i'll have create phone call users service in order right user names. not ideal, can live it.

what implementing purchase search based on user name? can expose api endpoint @ users service end receives query term, perform text search on user names in users service, , homecoming user details match criteria. @ purchase service, map relevant ids right names , show them in page. approach not ideal either.

am missing something? there approach implementing above? maybe fact i'm facing issue sort of code smell? love hear other solutions.

it's totally fine maintain appropriate info in different databases, it's called polyglot persistence. yes, maintain user info , info purchases separately , utilize message queue sync. millions of users seems fine me, it's scalability, not design issue ;-)

in case of search - want search more username, right? so, if utilize message queue update info between services can route info elasticsearch, example. , elasticsearch perspective doesn't matter field index - username or product title.

web-services architecture microservices

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -