Discussion about this post

User's avatar
Nikhil Garg's avatar

Multi-tenancy is where scalability meets complexity, i really liked how you made it clear and practical.

Expand full comment
Saravana Thiyagarajan's avatar

I feel using same database or same logical queue for all tenets leads to Noisy neighbour issue.

One tenet can push more jobs into queue and an other tenant would be waiting.

I have faced this same issue where we 1000 clients. We go with same approach where single central database to hold tenet meta data.

High our product is analytics tool which helps you to configure your database and you can do reporting with different type of reports from table to charts and pivots.

Our setup single version of application server and singe global redis queue and work setup for 1000 clients.

Problem we have dashboard which is collection of reports. A dashboard can have 50 reports. Which means 50 sql queries. We thought to optimise this for better user experience.

Previous user need to wait for 50 queries to finish. So I implemented a queue job style to handle the query and websockets to send data to frontend.

Our stack Laravel 10 and vue 2. It look pretty decent on our staging environments . Once it on prod things are still slow. Tenant starts complaining us.

We figure out having single queue was problem. We raised works count but it started creating context switching issue. It doesn’t solved. Later we made a logical queue inside a redis.

Idea is having separate logical queue with tenant I’d. Now we avoided noisy neighbour issue. Still the context switching issue is there as we need 1000 process on worker servers.

Later we landed on ideal middle ground not all tenant are having high traffic. So now we have done sort of consistent handling logic to push job on queue with flags for those clients and we have spinned a separate workers for those client.

Expand full comment
1 more comment...

No posts

Ready for more?