I am writing a High Performance ASP.NET Json API with soon > 1000 Request/Second. All my logic and processing is done in an IHttpHandler. I measured via Stopwatch Class and the handler finishes a request in around 0,1 - 0,5 Millisecond.
我正在写一个高性能的ASP。NET Json API与> 1000请求/秒。我所有的逻辑和处理都是在IHttpHandler中完成的。我通过秒表类进行测量,处理程序在大约0,1 - 0,5毫秒内完成一个请求。
But it seems IIS and/or other HTTPHandlers (Modules?) are taking away a lot of performance. Can i measure that somehow ? How much overhead will a request produce in IIS when configured for best performance ?
但似乎IIS和/或其他httphandler(模块?)正在剥夺很多性能。我能以某种方式衡量吗?在配置为最佳性能时,请求在IIS中会产生多少开销?
Will removing all those HTTPHandlers help, or are there other tricks to speed it up? I dont need much of the ASP.NET Featureset besides Session (could even workaround that if it give a significant performance boost).
移除所有的httphandler会有帮助吗?还是有其他的方法来加速它?我不需要太多的ASP。除了会话(如果它有显著的性能提升的话,它甚至可以解决这个问题)。
2 个解决方案
#1
9
Measuring performance of a web server is no trivial task. A few things to consider:
度量web服务器的性能并不是一项简单的任务。有几点需要考虑:
- Find the actual bottleneck. This can be memory, disk access, caching, database access, network latency etc. Use a memory profiler, or other performance profiler to find out.
- 找到真正的瓶颈。这可以是内存、磁盘访问、缓存、数据库访问、网络延迟等等。使用内存分析器或其他性能分析器来查找。
- Use WireShark to find the difference between how long the request is on your machine and how long your code runs.
- 使用WireShark来找出请求在您的机器上的时间和代码运行的时间之间的差异。
- Try other configurations. Give ASP.NET more memory. Upgrade the test system. I.e., going from 8GB / 2.5GHz with 600 requests/sec to 16GB / 3.0GHz can yield 6500 requests/sec. Performance growth is often not linear. See this document from Microsoft.
- 尝试其他配置。给ASP。更多的内存。升级测试系统。即。,从600个请求/秒的8GB / 2.5GHz增加到16GB / 3.0GHz可以产生6500个请求/秒。性能增长通常不是线性的。请参阅来自微软的这个文档。
- Consider adding an extra machine. This can yield up to a 50 or even higher performance upgrade depending on how you configure it. See again that document from MS.
- 考虑增加一台额外的机器。这可以产生50甚至更高的性能升级,这取决于您如何配置它。请再次查看来自MS的文档。
- Check these hints by Jon Skeet. The comment thread reveals some non-obvious potential bottlenecks as well.
- 看看Jon Skeet的这些提示。评论线程还揭示了一些不明显的潜在瓶颈。
NOTE 1: know your tools. ASP.NET runs each request in its own thread. Thread swapping is faster than process swapping, but it still requires time. If other handlers take time because they are in the request chain, it's beneficial to disable them.
注意1:了解你的工具。ASP。NET在自己的线程中运行每个请求。线程交换比进程交换要快,但是仍然需要时间。如果其他处理程序需要时间,因为它们位于请求链中,那么禁用它们是有益的。
NOTE 2: one of the original side-goals of * was to create a site in ASP.NET that had great performance on max 2 servers and could handle > 1Mln visitors per hour. They managed to do that. I believe they wrote some blogposts on it, but I don't remember where they are.
注2:*最初的一个目的就是在ASP中创建一个站点。它在max 2服务器上的性能很好,每小时可以处理> 1Mln访问者。他们设法做到了。我相信他们写了一些博客,但是我不记得他们在哪里。
#2
5
This is a very good question. I have noticed the same once you get into the single-millisecond range of response times, ASP.NET overhead starts to be noticable. I can confirm your observation.
这是一个很好的问题。我也注意到,一旦你进入到单毫秒的响应时间,ASP。净开销开始变得明显。我可以证实你的观察。
What I have done successfully is to find out, which HttpModules are registered (using IIS Manager) and disable all of them which I could possibly get rid of. The standard ASP.NET pipeline has a lot of modules and functionality configured.
我成功地做了一件事,就是找出哪些httpmodule是注册的(使用IIS管理器),并禁用所有我可以删除的。标准的ASP。NET管道具有许多模块和配置的功能。
If you need ultimate performance, you could of course use a tiny HTTP server library and get rid of almost all overhead that way. This would be so incredibly fast.
如果您需要最终的性能,当然可以使用一个小型的HTTP服务器库,并通过这种方式消除几乎所有的开销。这将是如此的快。
#1
9
Measuring performance of a web server is no trivial task. A few things to consider:
度量web服务器的性能并不是一项简单的任务。有几点需要考虑:
- Find the actual bottleneck. This can be memory, disk access, caching, database access, network latency etc. Use a memory profiler, or other performance profiler to find out.
- 找到真正的瓶颈。这可以是内存、磁盘访问、缓存、数据库访问、网络延迟等等。使用内存分析器或其他性能分析器来查找。
- Use WireShark to find the difference between how long the request is on your machine and how long your code runs.
- 使用WireShark来找出请求在您的机器上的时间和代码运行的时间之间的差异。
- Try other configurations. Give ASP.NET more memory. Upgrade the test system. I.e., going from 8GB / 2.5GHz with 600 requests/sec to 16GB / 3.0GHz can yield 6500 requests/sec. Performance growth is often not linear. See this document from Microsoft.
- 尝试其他配置。给ASP。更多的内存。升级测试系统。即。,从600个请求/秒的8GB / 2.5GHz增加到16GB / 3.0GHz可以产生6500个请求/秒。性能增长通常不是线性的。请参阅来自微软的这个文档。
- Consider adding an extra machine. This can yield up to a 50 or even higher performance upgrade depending on how you configure it. See again that document from MS.
- 考虑增加一台额外的机器。这可以产生50甚至更高的性能升级,这取决于您如何配置它。请再次查看来自MS的文档。
- Check these hints by Jon Skeet. The comment thread reveals some non-obvious potential bottlenecks as well.
- 看看Jon Skeet的这些提示。评论线程还揭示了一些不明显的潜在瓶颈。
NOTE 1: know your tools. ASP.NET runs each request in its own thread. Thread swapping is faster than process swapping, but it still requires time. If other handlers take time because they are in the request chain, it's beneficial to disable them.
注意1:了解你的工具。ASP。NET在自己的线程中运行每个请求。线程交换比进程交换要快,但是仍然需要时间。如果其他处理程序需要时间,因为它们位于请求链中,那么禁用它们是有益的。
NOTE 2: one of the original side-goals of * was to create a site in ASP.NET that had great performance on max 2 servers and could handle > 1Mln visitors per hour. They managed to do that. I believe they wrote some blogposts on it, but I don't remember where they are.
注2:*最初的一个目的就是在ASP中创建一个站点。它在max 2服务器上的性能很好,每小时可以处理> 1Mln访问者。他们设法做到了。我相信他们写了一些博客,但是我不记得他们在哪里。
#2
5
This is a very good question. I have noticed the same once you get into the single-millisecond range of response times, ASP.NET overhead starts to be noticable. I can confirm your observation.
这是一个很好的问题。我也注意到,一旦你进入到单毫秒的响应时间,ASP。净开销开始变得明显。我可以证实你的观察。
What I have done successfully is to find out, which HttpModules are registered (using IIS Manager) and disable all of them which I could possibly get rid of. The standard ASP.NET pipeline has a lot of modules and functionality configured.
我成功地做了一件事,就是找出哪些httpmodule是注册的(使用IIS管理器),并禁用所有我可以删除的。标准的ASP。NET管道具有许多模块和配置的功能。
If you need ultimate performance, you could of course use a tiny HTTP server library and get rid of almost all overhead that way. This would be so incredibly fast.
如果您需要最终的性能,当然可以使用一个小型的HTTP服务器库,并通过这种方式消除几乎所有的开销。这将是如此的快。