Pion is asynchronous, so 8 threads should be able to handle many thousands of concurrent connections. Unless you have some sort of blocking code in your handler, there is probably no reason to increase it beyond the number of physical cores (8 threads should fully utilize 8 physical cores).
From: Rohan Shetty <she...@ya...<mailto:she...@ya...>>
Reply-To: Rohan Shetty <she...@ya...<mailto:she...@ya...>>
Date: Thursday, January 8, 2015 at 9:30 PM
To: "pio...@li...<mailto:pio...@li...>" <pio...@li...<mailto:pio...@li...>>
Subject: [pion-users] How to increase the the "concurrent processing threads" in pion - Handle leak
Hi,
I use the following code, which is working fine
pion::http::server_ptrm_HttpServer;
unsigned int m_iPort = 0
//Listen only in the loopback interface
boost::asio::ip::address addr(boost::asio::ip::address_v4::loopback());
// If port =0, then the HttpServer would take a free available port
boost::asio::ip::tcp::endpoint endpoint(addr, m_iPort);
// Create a web server and specify the port on which it will listen.
m_HttpServer = pion::http::server_ptr(new pion::http::server(endpoint));
m_HttpServer->start();
Following is the handler used for testing this.
void CPalHttpServer::RequestHandlerForPalRoot(constrequest_ptr & PtrHttpRequest,
connection_ptr & PtrTcpConn)
{
string HELLO_HTML = "<html><body>PAL Service!</body></html>";
response_writer_ptr writer(response_writer::create(PtrTcpConn, * PtrHttpRequest,
boost::bind(&connection::finish, PtrTcpConn)));
writer->write(HELLO_HTML);
writer->send()
}
By default PION supports around 8 threads, which will limit only 8 concurrent HTTP requests.
I tried the following code, in which I have tried to increasing the thread to 100. Is this the right ?
pion::http::server_ptrm_HttpServer;
pion::single_service_scheduler m_DefaultScheduler;
m_DefaultScheduler.set_num_threads(100);
unsigned int m_iPort = 0
//Listen only in the loopback interface
boost::asio::ip::address addr(boost::asio::ip::address_v4::loopback());
// If port =0, then the HttpServer would take a free available port
boost::asio::ip::tcp::endpoint endpoint(addr, m_iPort);
// Create a web server and specify the port on which it will listen.
m_HttpServer = pion::http::server_ptr(new pion::http::server(m_DefaultScheduler, endpoint));
m_HttpServer->start();
Problem: There is couple of handle leaks for every http request processing.
i.e when client sends the http request, I could see couple of handle leaks.
Any help is appreciated
Regards,
Rohan
|