Pages

Friday, November 25, 2011

Sporadic delays in BeginRequest of ASP.NET webpages

I've been investigating why some of our ASP.NET webpages sporadically take 10-20 seconds to load, when on average they take 500-700 ms.


The NewRelic instrumentation shows that the delay always happens due to uninstrumented code in BeginRequest.

13,812
100.00%
System.Web.HttpApplication.BeginRequest()0.000 s
0.0
0.00%
13 fast method calls0.000 s
0.0
0.00%
Aptimize.WebAccelerator.OptimizerModule.OptimizerModule_BeginRequest()0.000 s
0.0
0.00%
ASP.global_asax.Application_BeginRequest()0.000 s
0.0
0.00%
System.Web.Security.FormsAuthenticationModule.OnEnter()0.000 s
0.0
0.00%
System.Web.Handlers.ScriptModule.AuthenticateRequestHandler()0.000 s
0.0
0.00%
System.Web.Security.DefaultAuthenticationModule.OnEnter()0.000 s
0.0
0.00%
System.Web.Security.RoleManagerModule.OnEnter()0.000 s
0.0
0.00%
System.Web.Security.AnonymousIdentificationModule.OnEnter()0.000 s
0.0
0.00%
System.ServiceModel.Activation.HttpModule.ProcessRequest()0.000 s
0.0
0.00%
System.Web.Security.UrlAuthorizationModule.OnEnter()0.000 s
0.0
0.00%
System.Web.Caching.OutputCacheModule.OnEnter()0.000 s
0.0
0.00%
System.Web.Routing.UrlRoutingModule.OnApplicationPostResolveRequestCache()0.000 s
0.0
0.00%
System.Web.HttpApplication+MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()0.000 s
0.0
0.00%
System.Web.Routing.UrlRoutingModule.OnApplicationPostMapRequestHandler()0.000 s
13,578
98.31%
Uninstrumented time 0.000 s
0.0
0.00%
4 fast method calls
After some digging around, I found a few articles that hint this could be due to deadlock issues with Microsoft session module implementation. When you have a page, containing several iframes, these iframes can be concurrently requesting the same session ID from a session state resulting in a deadlock and a delay.

There's a good StackOverflow discussion right here which Demis Bellot pointed me to:
What they recommend to do is to reimplement the session module using MSDN's
custom session handler class (http://msdn.microsoft.com/en-us/library/system.web.sessionstate.sessionstateutility.aspx). The only problem is that that class is not thread safe.

So I started tweaking the class and came up with the following source code, which you can download from: http://www.cs.yale.edu/~yampolsk/SessionDemo.rar
. I am planning to put it into Production next week and measure the results.
Simple Apache benchmarking of default MS session handler and this one, result in almost identical performance.





Reactions:

81 comments:

I'm experiencing something similar. What were your results with your code?

The results were positive. It helped.
We had to further tweak the session module to persist the data in a global distributed cache (otherwise it didn't get shared between servers). But the timeouts in beginrequest got eliminated.

Would you mind setting up a small project on e.g. GitHub with the source code so that the community can give coordinated feedback and maybe fix/improve your solution in case of any problems or shortcomings? That would be a great move, I think :-)

Thanks anyway for writing this up. I also ran into this problem only thanks to New Relic, by the way.

Does this work with mode="StateServer"? We don't need cross-server state management but we don't want state disappearing every time we update our code, so that's why we use the built in state server. I looked at the code and I can't see any way this version explicitly supports StateServer, so I was wondering if maybe I'm just missing some implicit support?

Note, AngiesList implemented a custom session module using REDIS distributed cache:
https://github.com/angieslist/AL-Redis

You could try using that for cross-server state management.

Hello Alaxander,

Thanks a lot for the nice post! We also see similar pattern in our New Relic for our ASP.NET application. I need your expert views on following things:

1. Our application is using "System.Web.SessionState.SessionStateModule" -- I think this is the default one for .NET correct? And this also has same issue what you have described in this post? Our config. is as below:


2. What's your inputs fro Apache Benchmarking? As per my understanding with your improved logic Req/Sec should increase and Response time should decrease -- correct? Or any other things to monitor?
3. This issue exists for all ASP.NET applications? Or any specific ASP.NET version? This issue applies to all heavy request loaded ASP.NET application only correct?

Keenly waiting for your expert views!

Thanks again,
Kiran

Tks for the post and code.
I try to use it in my project. i added the relevant code from your download, compiles well, and added:


to httpmodul section.
It works... but when i put breakpoints all over your code, it never hits, so it looks for me, as it is not used in my project, means, the session runs with normal asp.net session inproc implementation. can that be ? do i miss something additional to the webconfig ?

This comment has been removed by the author.

Thanks for article. However it is not clear if this module is going to work with standard MS SQL Session provider. Module should call provider, right? Could you clarify please?

Thanks for your crystal clear explanation.

prathap
dot net training in chennai

Coding is very useful..Thanks for the sharing the post with lot of information..

Mariposa negra (African american Butterfly): This kind of gripping motion picture uses fake omega, any university trainer searching for payback for your murder regarding the girl fiancé. Made in the particular 1990s, this kind of motion picture is approximately corruption and also payback, and also occasionally will be dim yet alluring. L . a . Teta Asustada (The particular Dairy regarding Sorrow): Peru’s initial Oscar nominated motion pictures justifies every one of the consideration that omega replica sale. That uses the character Fausto, a girl having difficulties to be able to appropriately bury the girl mommy. From the particular outskirts regarding Lima, the particular extraordinary conflict motion picture provides eerie Quechua melodies plus a fantastic plot of land. When preparing to get a contest or perhaps education being competing, despite having one self, iwc replica uk in which help observe and also document any runner's info are usually crucial. Mileage, place, heartrate and also rate are typical important factors which can be effortlessly identified using these gadgets. This is really beneficial details to learn just what locations needs to be dedicated to. Several also have the capability of being plugged into a pc so that the particular person can easily examine and also examine the data above a great elapsed breitling replica uk of energy. Education to get a contest can be a extended and also monotonous method being a runner searches for to boost equally velocity and also staying power. The size of the particular contest can be a important determinant inside the amount of a long way they must sign weekly. Furthermore, many individuals normally have any cartier replica for your time frame where they wish to combination the finish series. They want any way in which to be able to continually evaluate the particular development made in each and every work.


I am following your blog from the beginning, it was so distinct & I had a chance to collect conglomeration of information that helps me a lot to improvise myself.
Regards,
Web design training in chennai

Indeed it all begins at home and then school and then college. But it is at the college stage where you need to make some really important decisions. From what you are going to study to where you are going to study, these are crucial questions that need answers Pass Guide 70-411 PDF

Your article is so informative. The field of web design and development is all about creating attractive website that provide smooth browsing experience to user. Your website is strict example of attractive website design. Web designing course in Chennai

Looking for a career in technology industry? Wonder what are the languages that will give just the right start to your career?
Over to the hottest programming languages you can learn in 2015.


Dotnet Training

There are lots of information about hadoop have spread around the web, but this is a unique one according to me. The strategy you have updated here will make me to get to the next level in big data. Thanks for sharing this.

.net training in chennai

Thanks for the notes that you have published here. Though it looks familiar, it's a very good approach you have implemented here. Thanks for posting content in your blog. I feel awesome to be here.

cloud computing training chennai
Cloud computing training centers in chennai
hadoop training in chennai

Informative article!!! Being flagship too for Microsoft, Asp.Net is loaded with various essential tools that allow developers to build robust web applications. PHP Training

This information is impressive; I am inspired with your post writing style & how continuously you describe this topic. After reading your post, thanks for taking the time to discuss this, I feel happy about it and I love learning more about this topic.
Regards,
Python Training in Chennai|Python Training

There are lots of information about latest technology, like Hadoop cluster is a special type of computational cluster designed specifically for storing and analyzing huge amounts of unstructured data in a distributed computing environment. This information seems to be more unique and interesting. Thanks for sharing.
Big Data Training Chennai | Big Data Training | Hadoop Course in Chennai

I am reading your post from the beginning, it was so interesting to read & I feel thanks to you for posting such a good blog, keep updates regularly.
Regards,
Python Training in Chennai|Python Training|Python Training Institutes in Chennai

Learning new technology would give oneself a true confidence in the current emerging Information Technology domain. With the knowledge of big data the most magnificent cloud computing technology one can go the peek of data processing. As there is a drastic improvement in this field everyone are showing much interest in pursuing this technology. Your content tells the same about evolving technology. Thanks for sharing this.

Hadoop Training in Chennai |
Hadoop Training Chennai

I am reading your post from the begining, it was nice to read and you are mentioned so many important points to improve my skill set as good way, keep sharing
Regards,
sap training in Chennai|SAP Course in Chennai|SAP Training|SAP training in chennai

Excellent post!!! The future of .net application development is on positive note. It offers huge career prospects for talented professionals all over the world. Training on .net technology will ensure good salary package. DOT NET Training in Chennai | .NET Training in Chennai

Excellent post!!! Selenium automation testing tool makes your software validation process lot simpler. Keep on updating your blog with such awesome information. Selenium Training in Chennai | Selenium Course in Chennai | Best Selenium training institute in Chennai

Web technology is the best thing that is dominating the world today(web designing course in chennai ), every business needs a web developement in house team(web designing course). The content you have provided here also tells the same. Thanks for providing such a wonderful informtaion in here(web designing training in chennai). Keep blogging like this.

Assam 2564 Police Constable Recruitment 2016 Apply Online


Amazing information given by author, Keep writing more and more..........

Naval Dockyard Visakhapatnam Tradesman Skilled Recruitment 2016

First i would like greet author, thanks for providing valuable information........

Updating with the latest technology and implementing it is the only way to survive in our niche. Thanks for making me understand through this article. You have done a great job by sharing this content in here. Keep writing article like this.

DOT NET Training in Chennai | Best DOT NET Training in Chennai | DOT NET Training Chennai

Latest technology have created a greater impact over testing web applications. This vital in identifying important issues that raises in web appplications. Thanks for sharing this information in here. Keep blogging article like this.

Selenium training in chennai | Selenium training chennai | Best selenium training in chennai

Tết đến, xuân về, nhu cầu mua sắm của khách hàng tăng cao. PHần lớn, nhiều khách hàng thường sử dụng phương pháp mua hàng trực tuyến để tiết kiện được nhiều thời gian. Hơn nữa, hầu hết khách hàng đều chọn kênh mua sắm lớn Amazon. Dịch vụ
mua hàng trên amazon về việt nam sẽ sẽ cho quý khách loại bỏ những trở ngại, khó khắn khi mua hàng tại các nước bạn. Chúng tôi còn nhận order hàng từ nhật về việt nam với thời gian chờ nhanh, chi phí thấp, an toàn và uy tín. nhận chuyển hàng từ nhật bản về việt nam . ĐẶc biệt khi hàng về tại việt nam, chúng tôi sẽ giao hàng tại địa chỉ của quý khách hàng yêu cầu. Tại thủ đô hà nội và tphcm chúng tôi sẽ miễn phí cước vận chuyển. nhận ship hàng từ nhật về tphcm nhận ship hàng từ nhật về hà nội
Mong rằng quý khách sẽ hài lòng với
dịch vụ vận chuyển hàng từ nhật về việt nam.

Thanks for your informative article. Android SDK allows you to create stunning mobile application loaded with more features and enhanced priority. With basis on Java coding language, you can create stunning mobile application with ease. Android Training Institutes in Chennai | Android Training in Chennai

When you're tired, you want to relax after a stressful working hours, you need to have time to take care of the kids active.
Please visit our website and play exciting flash games.
Thanks you for sharing!
http://www.friv4-online.com Friv 4

Pretty content with useful information. Angularjs is a structural framework for developing the dynamic web applications. Angular's data binding and dependecy injection is capable of eliminating much of the code.
angularjs training in chennai | angularjs training chennai

This content is written very well. Your use of formatting when making your points makes your observations very clear and easy to understand. Thank you.
- usps tracking
- iphone 7 release date
- netflix

The professionals who have finished programming must have the knowledge of html5.The HTML5 is developed to solve the compatibility problem that affects the current standard of html4. The goal of html5 is to support the audio, video and canvas tags.
HTML5 training in Chennai | Html5 training chennai

pretty content. Angular JS is a structural framework for dynamic web application and angular's data binding eliminates much of the code that you would otherwise write it.
Angularjs Training in Chennai | Angularjs training Chennai

Excellent post!!! Selenium automation testing tool makes your software validation process lot simpler. Keep on updating your blog with such awesome information.
Best Selenium Training Institute in Chennai|Selenium Training in Chennai

It's an precious information, happy to see your valuable post.
Regards,
Loadrunner Training in Chennai|Qtp training in Chennai

You article is describe in a good manners with best possible way and now I am follow your site on daily basis and I like a very much your blog, so keep posting with such a nice article and we are also write something about Indian festival if anyone interested them, so checkout link all

Eid Mubarak Images
Eid Mubarak 2016
Friendship Day Images
Happy Dussehra Images
Happy Navratri Images
Independence Day Images
Raksha Bandhan Images
Happy Diwali Images
Happy Teachers Day Quotes Wishes
Happy 4th of July Images Quotes
Happy Fathers Day 2016
Happy Fathers Day

The strategy you have posted on this technology helped me to get into the next level and had lot of information in it.
digital marketing course in chennai | digital marketing training

The future of software testing is on positive note. It offers huge career prospects for talented professionals to be skilled software testers. Software testing training|Software training|Software testing training in chennai

Hi, I wish to be a regular contributor of your blog. I have read your blog. Your information is really useful for beginner. I did Selenium Training in Chennai at Fita training and placement academy which offer best Selenium Training with years of experienced professionals. This is really useful for me to make a bright career.
Regards,
Selenium training in Chennai | Selenium Course in Chennai | Best Selenium training institute in Chennai

Excellent post!!!. The strategy you have posted on this technology helped me to get into the next level and had lot of information in it.
salesforce training in chennai | salesforce training institute in chennai

Excellent post!!!. The strategy you have posted on this technology helped me to get into the next level and had lot of information in it.
Hadoop Training Chennai | PHP Training in Chennai

Good post. Glad to find your blog. Thanks for sharing.


seo training institute in chennai

Very nice post. I like your blog. Thanks for sharing.

magento training in chennai

Android Application development is the combination of creativity and science. With these you can create the android application in an easy way. Get start your career in android field. It offers huge career aspects for talented professionals.
Android Training Institutes in Chennai | Android Training in Chennai


Informatica is a software development company. It delivers management software and data integration products for the cloud and big data.Start to learn Informatica course in Chennai at FITA.They are offering a wonderful training with experienced professionals.
Informatica Training in Chennai | Informatica institutes in Chennai

Well Said, you have furnished the right information that will be useful to anyone at all time. Thanks for sharing your Ideas.
Hadoop Training in Chennai | Hadoop Training Chennai

Post a Comment