facebook / proxygen

A collection of C++ HTTP libraries including an easy to use HTTP server.
Other
8.03k stars 1.47k forks source link

Concurrent performance supported by the HTTP server #482

Closed liangchenBoom closed 3 months ago

liangchenBoom commented 3 months ago

Hi, everyone. I'm a rookie, and I've gotten into some trouble. I'm building a sample Http server like echo server example, then I use Jmeter with up to 64 concurrent requests to do concurrent http post tests. I saw the great concurrency performance in the graph below[1]. That's what I want. So this is my structure,the sample http server on one server, jmeter as http client on another server, their hardware devices are Intel(R) Xeon(R) Gold 6151 CPU @ 3.00GHz with 36 physical cores, the ping between them is 0.045ms.

The sample http servercode is like this(from another issues):

void RequestHandler::onEOM()  noexcept {
  // give those separate worker threads the EventBase* from the RequestHandler thread
  folly::EventBase* eventBase = folly::EventBaseManager::get()->getEventBase();

  threadPool->add([downstream_, eventBase]() {
    //do some work in there, note that there is very little work here, and it takes almost no time.
    eventBase->runInEventBaseThread([&downstream_]() {
      ResponseBuilder(downstream_).status(...).header(...).body("").sendWithEOM();
    }   
  }
// the other code like echo server example
 HTTPServerOptions options;
  options.threads = static_cast<size_t>(FLAGS_threads);
  options.idleTimeout = std::chrono::milliseconds(60000);
  options.enableContentCompression = false;
  options.handlerFactories =
      RequestHandlerChain().addThen<EchoHandlerFactory>().build();
  options.h2cEnabled = true;
}

The test method is to adjust FLAGS_threads and then use Jmeter to test different concurrent requests, record the best performance.

FLAGS_threads 1 2 3 4 5 8 12 24 64
ops/s 8000 16000 24000 28000 29000 29000 27000 27000 26000

This is different from the data in [1]. Can someone help me out here? Thanks for your help. [1]image