1

Good day!

I've found interesting behaviour for both LAMP stack and ASP.NET.

The scenario:

There is page performing task in 2-3 minutes (making HttpWebRequest for ASP.NET and curl for PHP). While this page is processed all other requests to this virtual host from the same browser are not processed (even if I use different browsers from one machine). I use two pages written in PHP and C#.

I've tested with Apache+PHP in both mod_php and fast_cgi modes on Windows and Debian. For ASP.NET I use IIS6 (with dedicated app pool for this site and with default app pool) and IIS7 in integrated mode.

I know that it is better to use async calls for such things, but I'm just curious why single page blocks the entire site and not only the thread processing the request?

Thanks in advance!

artvolk
  • 9,448
  • 11
  • 56
  • 85

5 Answers5

1

It seems you open standard php session that is open until end of request. That means session file is locked. Use session_write_close() soon as possible if you don't need session data already.

Rix Beck
  • 126
  • 2
  • Yes you are right, the issue was resolved via `session_write_close()`, I just forgot to post solution here. Thanks! – artvolk Dec 13 '11 at 14:31
0

I don't think it's blocking the site; I would suspect that the open connection is blocking the client from making more requests. Have you proven that other machines can't use the site while your long-running request is in progress?

Dan Puzey
  • 33,626
  • 4
  • 73
  • 96
  • I have trying to use another browser (not another window, another program) from the same machine. As far as I understand things this should create another processing thread for new requests. – artvolk Mar 14 '10 at 10:23
  • Except not if your local machine already has an open connection to the same server on the same port. I repeat my question: have you proven that *other machines* can't use the site? I don't think you've proven that the server is blocked yet. – Dan Puzey Mar 14 '10 at 11:43
  • I have tested from other PC standing near. While my page is performing HttpWebRequest, the site is blocked for this PC too. Both PCs are behind the same NAT box – artvolk Mar 14 '10 at 12:57
0

If you only see a single request coming to the app the only thing I can think of is a global lock somewhere in the pipeline.

The lock can be explicit (you wrote the lock statement) or implicit. If you can see several requests - it can be due to the thread pool exhaustion.

Keep in mind that in addition to the cap on the number of threads used to process incoming web requests there is a separate cap on the number of simultaneous outgoing web requests through HttpWebRequest and by default this limit is very low - if I remember correctly 2 per CPU. I do not remember the name of the setting in the web.config, but will try to look it up.

In any case posting code would give us a better chance to assist you

mfeingold
  • 7,094
  • 4
  • 37
  • 43
  • Thank you for the response, do you mean this: http://support.microsoft.com/kb/821268 But what about PHP and Apache? Why the same behaviour?.. – artvolk Mar 14 '10 at 10:26
0

I've definitely noticed this behavior while debugging ASP.NET applications, but I have always just assumed it was a debug config issue. Are you building everything in release mode and have debugging turned off in your web.config?

Bryan
  • 8,748
  • 7
  • 41
  • 62
0

ASP.NET applications have a global session lock.

Use EnableSessionState="ReadOnly" for WebForms or [SessionState(SessionStateBehavior.ReadOnly)] for MVC. It will prevent the lock (of course you can't write anything to a read-only session).

I just discovered why all ASP.Net websites are slow, and I am trying to work out what to do about it

Community
  • 1
  • 1
Der_Meister
  • 4,771
  • 2
  • 46
  • 53