Home > Software engineering >  Consult ace and predecessors, how to efficiently access the database on the server program.
Consult ace and predecessors, how to efficiently access the database on the server program.

Time:11-02

Many clients using A TCP connection server, customers frequently do operations such as query balance, the database on the server B, using MySQL, in order not to let the database becomes the bottleneck of the whole system, I now think of the two schemes:

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 superior

CodePudding user response:

SQL Server can see sqldependency, other database triggers can be used to call an external application to notice,

CodePudding user response:

refer to the second floor zyq5945 response:
sqldependency under SQL Server can see, other database triggers can be used to call an external application to notice,

Behind you said that method specifically how I won't, scheme ii with asynchronous HTTP API, please?

CodePudding user response:

Their top, waiting for,

CodePudding user response:

Trigger calls the Java programs, such as through the program to inform the client data has changed,

CodePudding user response:

memcache

CodePudding user response:

reference 5 floor zyq5945 reply:
trigger calls the Java programs, such as through the program to inform the client data has changed,

I don't want to monitor database data changes, I want to access the database by means of asynchronous,

CodePudding user response:

Write their own server update, send notification to the server, the server to broadcast to the client,

CodePudding user response:

It seems that everyone understand became database monitoring
  • Related