Skip to content

Improve ASP.NET performance by up to 13% #314

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jun 7, 2013
Merged

Improve ASP.NET performance by up to 13% #314

merged 11 commits into from
Jun 7, 2013

Conversation

MalcolmEvershed
Copy link
Contributor

On my setup, this improved the performance of the 'json' test by 13%:

  1. Disable IIS HTTP logging to match the other tests. (3-5%)
  2. Remove unnecessary HTTP response headers to match the other tests. (0%, but should probably be done anyway)
  3. Disable support for direct access of *.cshtml and *.vbhtml files since we use MVC routing functionality instead. (13%) I identified this issue by using the Windows Performance Toolkit to profile the code.

FYI: @pdonald, @micahasmith, @ollyw, @rafaelsc

P.S. This branch also includes some other fixes from my parent master branch. I didn't intend to include those changes with these performance improvements, but I couldn't find a way to back them out. In the future, to avoid this problem, I will keep my master branch clean and only put changes in branches off of my master branch (I think that makes sense).

On Ubuntu Server, the hard limit is 4096, which is less than the
soft limit of 8192 that we're trying to use. Thus, to really use
a soft limit of 8192, we need to also boost the hard limit to
8192.
Tests expect to be able to start their own desired http server on
Apache's configured port.
… net.core.somaxconn=5000

When running tests that accessed MySQL, I was getting errors like:

BENCHMARKING Query ... [MySQL] 2013/05/23 00:57:04 packets.go:31: EOF
2013/05/23 00:57:04 Error scanning world row: driver: bad connection
exit status 1

Debugging this showed that the web server box had more connections to MySQL
than expected (i.e. netstat on the MySQL box showed 100 TCP connections, but
the web server box showed 1200). So there was some sort of TCP problem, perhaps
lost ACKs as described in http://www.evanjones.ca/tcp-stuck-connection-mystery.html .

Looking at the MySQL documentation for back_log (http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#sysvar_back_log),
it suggests that the OS setting needs to be greater than or equal to back_log. Thus,
we need to set net.core.somaxconn as big as our back_log value.

I tried this and the connection problems went away.
Sometimes the ActivePerl HTTP server returns a 404 for a URL that should work,
so retry it until it works, but up to a max number of retries. And delay
a little in between.
Match the overall policy of the other framework benchmarks.

On my setup, this improves the requests/sec of a test like 'json' by 3-5%.
This removes:

X-AspNetMvc-Version: 4.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET

I didn't see any performance improvement, but this is probably a good idea
in case the extra bytes cause another network packet to be needed,
compared to other frameworks.
We don't need to access URLs like this because we use MVC and URL routing.

On my setup, this improves the performance of the 'json' test by 13%.
@pdonald
Copy link
Contributor

pdonald commented May 30, 2013

For the record, I also disabled IIS HTTP logging in another pull request.

I don't think removing other response headers is necessary, especially since it doesn't improve performance in any way and the goal of these framework benchmarks is to be realistic. But that is just my opinion.

<add key="webpages:Enabled" value="false" /> however is a good find. Views\Web.config already has it but it looks like the json test was also using it, even though it doesn't use any views. Interesting.

@bhauer
Copy link
Contributor

bhauer commented May 30, 2013

Thanks for the updates @MalcolmEvershed and @pdonald. Glad to hear about the 13% performance bump from a small configuration change!

For response headers, we specify a minimum set [1], but additional headers that are conventionally enabled by the platform or framework should be retained to be realistic as @pdonald points out. Our findings to-date have been that response headers only play a detectable role in performance when our gigabit Ethernet becomes saturated.

[1] http://www.techempower.com/benchmarks/#section=code

@MalcolmEvershed
Copy link
Contributor Author

Thanks guys. I reverted the HTTP header commit and the HTTP logging commit.

@pfalls1 pfalls1 merged commit 24e188b into TechEmpower:master Jun 7, 2013
@MalcolmEvershed MalcolmEvershed deleted the performance branch June 7, 2013 21:54
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.

4 participants