Skip to content

Performance fix by caching run methods#49

Merged
ThatRendle merged 1 commit into
ThatRendle:masterfrom
nordbergm:performance
Jan 30, 2013
Merged

Performance fix by caching run methods#49
ThatRendle merged 1 commit into
ThatRendle:masterfrom
nordbergm:performance

Conversation

@nordbergm

Copy link
Copy Markdown

I've run performance tests using WeigHTTP against a simple REST endpoint, like this one:

[UriTemplate("/objects/{Id}")]
public class GetObjectById : IGet, IOutput<GetObjectResponseDto>
{
    public Status Get()
    {
        Output = new GetObjectResponseDto
            {
                Id = Id
            };

        return Status.OK;
    }

    public int Id { get; set; }
    public GetObjectResponseDto Output { get; private set; }
}

I noticed that on my machine I could only get a throughput of around 600 req/sec using IIS 8.0, and the follwing WeigHTTP parameters:

weighttp -n 10000 -c 10 -t 4 -k -H "Accept: application/json" http://localhost/objects/1

Compare this to MVC4 doing around 4500 req/sec and Web API around 5500 req/sec.

Using ANTS Profiler I've pinpointed the problem being that the handler run methods are compiled at each requests. Much of this was because the HandlerInfo variables were unique per request.

So, I've made a change so that HandlerInfo is a parameter to the lambda allowing the lambda to be cached under the handler type and HTTP method.

This has increased the throughput to around 4500 req/sec.

ThatRendle added a commit that referenced this pull request Jan 30, 2013
Performance fix by caching run methods
@ThatRendle ThatRendle merged commit 00119e2 into ThatRendle:master Jan 30, 2013
@ThatRendle

Copy link
Copy Markdown
Owner

Best. Pull request. Ever. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants