Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Http response thread pool #6687

Merged
merged 10 commits into from
Feb 14, 2019
Merged

Http response thread pool #6687

merged 10 commits into from
Feb 14, 2019

Conversation

heifner
Copy link
Contributor

@heifner heifner commented Jan 30, 2019

Change Description

  • Thanks go to @bspark8 Enable websocketpp part threading #6678 for testing and verifying the improvement of processing/sending http request on a different thread.
  • This PR adds a thread pool to the http_plugin used for processing/sending http requests.
  • Remove auto load of http_plugin in nodeos main.cpp since not all nodeos need the http_plugin and the extra threads it spawns.
  • Application logic is still processed on the application thread.
  • See Enable websocketpp part threading #6678 for additional info

Consensus Changes

None

API Changes

None

Documentation Additions

  • http_plugin has new option:
    --http-threads arg (=2) Number of worker threads in http thread pool

@bspark8
Copy link

bspark8 commented Feb 1, 2019

Thank you for reflecting idea !!
The original intent of the previous PR(#6678) was to process threading both parts receiving HTTP requests and responding to the HTTP requests because both parts were consuming almost same amount of cpu.
Instead of thread pool, I created a new io_context to be threaded separately and passed it to the acceptor of websocketpp.
So I would like to add some additional threading for the part that receives the HTTP requests. I would appreciate your feedback.

@heifner
Copy link
Contributor Author

heifner commented Feb 1, 2019

I missed that you are passing the new io_context to init. Thanks for pointing that out.

@heifner
Copy link
Contributor Author

heifner commented Feb 1, 2019

@bspark8 I've added a new io_context for the websocketpp server as you suggested.

plugins/http_plugin/http_plugin.cpp Outdated Show resolved Hide resolved
@heifner heifner changed the title Http response thread pool [WIP] Http response thread pool Feb 7, 2019
@bspark8
Copy link

bspark8 commented Feb 8, 2019

@heifner Thank you for additional threading for the part that receives the HTTP requests.
In addition, I did the same test that I did in the previous PR(#6678) in the current patch. Below is the result.

Current patch

  • About 1137 TPS (22% performance improvement)
  • Each thread CPU usage
    main: 88%
    receiving HTTP requests: 52%
    responding to the HTTP requests: 14%

@heifner heifner changed the title [WIP] Http response thread pool Http response thread pool Feb 12, 2019
@@ -138,6 +139,13 @@ namespace eosio {

websocket_server_type server;

uint16_t thread_pool_size = 2;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we still want to default to 2 threads, even though we can have 1?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we now only load http_plugin if we need it, sure.

@heifner heifner merged commit b4fc0cd into develop Feb 14, 2019
@heifner heifner deleted the http-threads branch February 14, 2019 16:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants