--
You received this message because you are subscribed to the Google Groups "seastar-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to seastar-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/seastar-dev/eeb9f386-37f5-4061-a491-c6bbde5287e4n%40googlegroups.com.
I figured that the simplest way of showing the problem is with a reproducible case.The following program is an http_server (no sharding for simplicity) that handles two requests fast & slow.Accessing the fast api is instantaneous and the slow api takes time (10 seconds). Note that the shard is idle while waiting for the slow api to complete#include <seastar/core/seastar.hh>#include <seastar/core/future-util.hh>#include <seastar/core/app-template.hh>#include <seastar/http/routes.hh>#include <seastar/http/request.hh>#include <seastar/http/function_handlers.hh>#include <seastar/http/httpd.hh>#include <seastar/core/sleep.hh>#include <seastar/coroutine/all.hh>#include <seastar/util/log.hh>#include <iostream>#include <chrono>using namespace std::chrono_literals;using namespace seastar;using namespace seastar::httpd;logger applog{"http-requests"};void set_routes(routes& r) {function_handler* h1 = new function_handler([](std::unique_ptr<http::request> req) -> future<json::json_return_type> {applog.info("{} slow", req->get_url());co_await seastar::sleep(10s);co_return json::json_return_type("json-future");});function_handler* h2 = new function_handler([](std::unique_ptr<http::request> req) -> future<json::json_return_type> {applog.info("{} fast", req->get_url());co_return json::json_return_type("json-future");});r.add(operation_type::GET, url("/slow"), h1);r.add(operation_type::GET, url("/fast"), h2);}int main(int argc, char** argv) {app_template app;return app.run(argc, argv, [] () -> future<int> {auto server = new http_server("seastar");set_routes(server->_routes);co_await server->listen(seastar::make_ipv4_address({1234}));co_await seastar::sleep(10000s);co_await server->stop();delete server;co_return 0;});}To see it an action just invoke two calls - trigger the slow endpoint and then the fast endpoint.curl -s "http://127.0.0.1:1234/slow"curl -s "http://127.0.0.1:1234/fast"The server will hang.My suggested fix is to invoke the actual handlers (in this case the function handler that sleeps) on a seastar::thread. Like that seastar will be able to handle concurrent requests.Hope this makes more sense now,Kfir.
Hey,
While working with the http_server I noticed that it only handles a single request per listener per shard at a time.
This implies that the implementation is limited to the number of parallel requests that can be handled. Assuming the server performs some heavy operation in the context of a single http request (e.g using some other service by its API) the shard will not be able to process any additional requests until the completion of the previous request.
This made me wonder, why not add some seastar::thread pool to the http server. The size of the pool can be configurable according to the application needs. Overcoming the limitation of a single connection per shard.
I didn't find any discussion on this topic in the community here. Figured that I will ask before implementing such a solution.Thanks in advance,
Kfir