Tsqldbserverhttpapi using the worker thread pool

Source: Internet
Author: User

Tsqldbserverhttpapi using the worker thread pool

When Tsqldbserverhttpapi is created, the default is to use single-threaded mode, and only one database connection is used, and the server should handle a large number of clients relying on only one worker thread (the main thread) and one database connection.

The main thread of the server is not too busy to die! Yes, clients don't wait to die!

Take code as proof:

Tsqldbserverhttpapi = Class (Tsqldbserverabstract)
Protected
Public
Publish the SYNDB connection on a given HTTP port and URI using. sys
-URI would follow the supplied adatabasename parameter on the given port
e.g. Http://serverip:8092/remotedb for
// ! Create (aprops, ' remotedb ');
-You can optionally register one user credential
Constructor Create (aproperties:tsqldbconnectionproperties;
Const ADATABASENAME:RAWUTF8; Const Aport:rawutf8=syndb_default_http_port;
Const ausername:rawutf8= '; Const apassword:rawutf8= ';
Ahttps:boolean=false;

Athreadpoolcount:integer=1; Use a total of one worker thread (the main thread, of course)
Aprotocol:tsqldbproxyconnectionprotocolclass=nil;
Athreadmode:tsqldbconnectionpropertiesthreadsafethreadingmode=tmmainconnection//using a database connection

); Override
End

Now the CPU is multi-core, for the hair does not open multi-work threads to deal with a large number of clients?

This, Mormot's author also thought for us. It's so happy!

As long as we specify the parameters when Tsqldbserverhttpapi is created:

Tsqldbserverhttpapi.create (DataBase, ' JJ ', ' 6789 ', ' admin ', ' admin ', False, 8, nil, tmthreadpool);

8: The thread pool creates 8 worker threads, which depends on the number of CPU cores.

Tmthreadpool: Use a database connection pool.

Tsqldbserverhttpapi using the worker thread pool

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.