Answer the question
In order to leave comments, you need to log in
How to work with several MySQL servers from under Node.JS at the same time?
Good afternoon.
There is a mobile project. Social network. All data is stored in MySQL, divided into logical shards. We store "hot data" in Redis, we also store the MySQL shard map there.
The back-end is written in node.js (express)
Interested in how you can quickly access different MySQL servers as part of processing one request to the back-end?
I'll give you an example.
The client accesses the back-end with a request for a user profile with id = 1, which we store on the mysql-1 server in shard #1. At the same moment, another client accesses the back-end with a request for a user profile with id = 2, which is stored on another server - mysql-2 in shard #2.
The number of mysql servers will grow. And the number of requests to the back-end will grow. Initializing a new connection to MySQL for each request to the back-end is probably not the best task.
Answer the question
In order to leave comments, you need to log in
Perhaps a stupid question: why not create separate connections to each server/shard at application startup?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question