You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I created a server using Proxygen based on EchoServer, since it is most based on folly, I post here for help.
The basic procedure to receive a request from a client, and then I create a thread to fetch data from db. After the data is fetched, send the response back to the client.
onEOM() {
auto eventBase = folly::EventBaseManager::get()->getEventBase();
thread t([&, eventBase]() {
auto d = fetch(); // call function to fetch data from db
eventBase->runInEventBaseThread([&]() {
sendResponse(d);
});
});
t.detach();
}
It works well for slow requests, but when I want to use wrk for benchmark, I found a problem.
Say the service is like ip2location, I use wrk to benchmark, like this:
Before it finishes, interrupt with Ctrl+C, and then do manual request with curl, like this:
curl -sv 'http://127.0.0.1:80/test?q=4.4.4.4'
The expected result for curl is for 4.4.4.4, but the actual result is for 8.8.8.8.
After several retry, it some times return the correct info, but most times are incorrect.
I tried to use Future and then pattern, but it has the same problem.
Future<string> getData(const string& ip) {
Promise<string> promise;
auto f = promise.getFuture();
auto ev = EventBaseManager::get()->getEventBase();
ev->runInLoop([promise = std::move(promise), &]() mutable {
auto d = fetch();
promise.setValue(d);
});
return f;
}
I also tried to set the idleTimeout to 100ms, and it still exists!
I tried to add flag in onError function, but it seems never called when I sends Ctrl+C.
I also tried to use folly::async to get a Future, and use the then pattern, but it only works with one CPUExecutor, if I set more than one, there will be crash saying runInEventBaseThread not the request one.
Please help to resolve this problem, thanks.
The text was updated successfully, but these errors were encountered:
I created a server using Proxygen based on EchoServer, since it is most based on folly, I post here for help.
The basic procedure to receive a request from a client, and then I create a thread to fetch data from db. After the data is fetched, send the response back to the client.
It works well for slow requests, but when I want to use wrk for benchmark, I found a problem.
Say the service is like ip2location, I use wrk to benchmark, like this:
wrk -t1 -c100 -d2m 'http://127.0.0.1:80/test?q=8.8.8.8'
Before it finishes, interrupt with Ctrl+C, and then do manual request with curl, like this:
curl -sv 'http://127.0.0.1:80/test?q=4.4.4.4'
The expected result for curl is for 4.4.4.4, but the actual result is for 8.8.8.8.
After several retry, it some times return the correct info, but most times are incorrect.
I tried to use Future and then pattern, but it has the same problem.
I also tried to set the idleTimeout to 100ms, and it still exists!
options.idleTimeout = std::chrono::milliseconds(100);
I tried to add flag in onError function, but it seems never called when I sends Ctrl+C.
I also tried to use
folly::async
to get a Future, and use the then pattern, but it only works with one CPUExecutor, if I set more than one, there will be crash saying runInEventBaseThread not the request one.Please help to resolve this problem, thanks.
The text was updated successfully, but these errors were encountered: