Solution a:
Server A put all the customer's request to the request queue, and then open 10-100 database operations threads, each thread to establish A database connection, server B threads from the request queue inside every time A request, use MySQL C API blocking operation database,
Scheme 2:
Add A server to provide C balance query operations such as HTTP API, in the form of A server using asynchronous HTTP requests to want to query the database server C,
I consider the pros and cons of the following:
One way can directly manipulate database, do not need again after another server C, feel the efficiency will be higher, but because each database thread is blocked the database operation, if the concurrency value is very big, such as more than 100 concurrent, will 100 threads also busy not to come over? If so, you need to add A thread, and then increase the thread will seriously affect the efficiency of server A CPU,
Scheme 2 no matter how hard it is concurrency, don't need A multi-threaded to manipulate the database, will be able to take, because use asynchronous HTTP server A feeling will greatly improve the efficiency, but C database operations need to add A server, from the point of overall efficiency, will also not high?
The above is I think of two solutions, elder people if there is a better solution please comment, such as scheme 1, how to use asynchronous operation database directly? I don't drive so multithreading,
CodePudding user response:
Superior superiorCodePudding user response:
SQL Server can see sqldependency, other database triggers can be used to call an external application to notice,CodePudding user response: