dmnapolitano / stanford-thrift

A Stanford CoreNLP server, with example clients, using Apache Thrift.
47 stars 8 forks source link

Try out different server configurations #7

Closed dmnapolitano closed 11 years ago

dmnapolitano commented 11 years ago

See https://github.com/m1ch1/mapkeeper/blob/eb798bb94090c7366abc6b13142bf91e4ed5993b/stubjava/StubServer.java

dmnapolitano commented 11 years ago

Should probably follow https://github.com/m1ch1/mapkeeper/blob/eb798bb94090c7366abc6b13142bf91e4ed5993b/bdbj/BdbJavaServer.java#L556

dmnapolitano commented 11 years ago

Ok I think we want a TThreadedSelectorServer.

dmnapolitano commented 11 years ago

See also https://issues.apache.org/jira/browse/THRIFT-1869

dmnapolitano commented 11 years ago

Ok, well, I can't tell the difference between what we have currently and the TThreadedSelectorServer. Seems to perform the same on our cluster. @dan-blanchard :confused:

dan-blanchard commented 11 years ago

Did you also get rid of the executorService thing?

dmnapolitano commented 11 years ago

Word @dan-blanchard , here's the current version of the code:

TServerTransport serverTransport = new TServerSocket(port);
TThreadPoolServer.Args args = new TThreadPoolServer.Args(serverTransport);
args.maxWorkerThreads(THREAD_POOL_SIZE);  // THREAD_POOL_SIZE = 10
args.processor(processor);
args.executorService(new ScheduledThreadPoolExecutor(THREAD_POOL_SIZE));
TServer server = new TThreadPoolServer(args);

and here's what I changed it to:

TNonblockingServerTransport trans = new TNonblockingServerSocket(port);
TThreadedSelectorServer.Args args = new TThreadedSelectorServer.Args(trans);
args.transportFactory(new TFramedTransport.Factory());
args.protocolFactory(new TBinaryProtocol.Factory());
args.processor(processor);
args.selectorThreads(4);
args.workerThreads(32);
TServer server = new TThreadedSelectorServer(args);

Basically directly copied from https://github.com/m1ch1/mapkeeper/blob/eb798bb94090c7366abc6b13142bf91e4ed5993b/stubjava/StubServer.java#L93

And yeah, on the client side, I changed it to use a TFramedTransport. If you don't use a TFramedTransport with the latter setup and TBufferedTransport with the former setup, Thrift just doesn't work. LOL

dmnapolitano commented 11 years ago

Ok, running mad things locally as opposed to through the grid. First, with the current setup, it was the same as it ever was, speed-wise (which is rather odd considering the lack of grid overhead, but granted, I am only running 10 TEthreads, lol). Now trying this new-style server, again locally with the 10 threads. So far I've noticed that it starts a million processes. :confused: But, it might always do that...

dmnapolitano commented 11 years ago

Ok, here's some timing information. On grid:

Running on one machine, 10 threads of TE:

@dan-blanchard also, just FYI, the only thing the Thrift server is being asked to do is return oneline parse trees of pre-tokenized sentences, one sentence at a time. :smile:

dmnapolitano commented 11 years ago

Ok, I'm getting consistently better performance, speed-wise (maybe once we move this into a crazy production environment it'll fall over :smile:) from the TThreadPoolServer (the current configuration). Increasing the number of threads helps dramatically. Think I'm going to stick with 32 threads and this configuration for now.