Search code examples
architecturemicroservicesrestful-architecture

Microservice architecture Flaws


We are facing performance related issues with microservice architecture.

Let's say there is microservice for user and account management. which have api's like

GET /users/{id} 
GET /users       (arrount 6 million users)

GET /accounts/{accountId}
GET /accounts 
and Other Operations on user and account

We have other microservice which track's user activities and list all the activities done by the user in his last login.

GET /user/activity/{userId}  (on an average 1000 to 10000 records)

We have protal for sales and marketing team to show individual user activities and user info and account info based on search criteria,

let's say search criteria is like : get all user activies who are located in colombia
Algorithm : 

1)Get /users ? location = colombia
2)then for individual user Get /user/activity/{userId}

it is like joining two tables from different databases.

it is very slow and creating lot of performance issues.

what i though of is replicating user table in other microservice by a job which makes sure it is up to date and using only one api like

GET /user/activities?location=colombia.

but replicating a table(user) is breaking the micro-service architecture main fundamentals

is there any other way to do it or support this type of filter criteria which join's tables from different micro-services.


Solution

  • You might be interested in using Command Query Responsibility Segregation

    See this implementing queries that need to retrieve data owned by multiple services.

    You can draw much inspirations from this example (Customers and Orders example of http://eventuate.io/).