RejectedSoftware Forums

Sign up

RESTful Service Performance Issue

Thank you for your assistance.

My Question:
Why does my REST service seem to perform so poorly using rest interfaces in dlang vibe.d when compared to creating request handlers manually?

More Information:
I have been prototyping a RESTful service using the vibe.d library. I'm running a test where a client sends GET and POST requests to the server with a payload of some given size, say 2048 bytes (i.e. the GET response would have 2k, the POST request would have 2k).

I'm using the registerRestInterface and RestInterfaceClient API in the vibe.d library to create my server and client sort of like this...

Server:

auto routes = new URLRouter;      

registerRestInterface(routes, new ArtifactArchive());

auto settings = new HTTPServerSettings();

settings.port = port;
settings.bindAddresses = [host];
settings.options |= HTTPServerOption.distribute;

listenHTTP(settings, routes);

runEventLoop();

Client:

IArtifactArchive archive = new RestInterfaceClient!IArtifactArchive(endpoint)  
IArtifactArchive.Payload result;  
result = archive.getContents(info.FileDescriptor, offset, info.BlockSize);

I'm not doing anything fancy in my interface. Just filling a byte array and passing it along. I know performance depends on many different things; however I seem to see about 160kB transfer rate when using REST interfaces in vibe.d and roughly 5MB transfer rate when using manual http request handlers like this :

void ManualHandleRequest(HTTPServerRequest req, HTTPServerResponse res) ...  
listenHTTP(settings, &ManualHandleRequest);

I really like the REST interface API, but I can't suffer that kind of performance loss in order to use it. Any thoughts on why it seems so much slower than the other method? Perhaps I'm configuring something wrong or missing something. I am somewhat new to the D programming language and the vibe.d library.

Thank you for your time!

Re: RESTful Service Performance Issue

On Mon, 15 Dec 2014 16:05:05 GMT, Bryan Wisdom wrote:

Thank you for your assistance.

My Question:
Why does my REST service seem to perform so poorly using rest interfaces in dlang vibe.d when compared to creating request handlers manually?

Hi,
Thanks for reporting the issue. It's hard to tell exactly from the code you posted, would you be willing to upload a test case somewhere (like a github repository) ? That would make it way easier to debug :)

From what I can see, there are 2 possibles causes:

  • The manual handler don't have to look routes up. Every request is directly mapped to your request handler.
  • Return from REST interface are always serialized (most likely the cause of the issue).

Again, if you upload an usable test case to github, I'll look into it.

Also, side note:

Server:

auto routes = new URLRouter;      

registerRestInterface(routes, new ArtifactArchive());

auto settings = new HTTPServerSettings();

settings.port = port;
settings.bindAddresses = [host];
settings.options |= HTTPServerOption.distribute;

listenHTTP(settings, routes);

runEventLoop();

I believe this code is in your module ctor (static shared this()) ? If so, you should not call runEvenLoop from here. If not, just ignore this comment :)