The whole site is blocked while one page is waiting for blocking (PHP, ASP.NET). What for?

Good afternoon!

I found interesting behavior for the LAMP and ASP.NET stack.

Scenario:

In 2-3 minutes, the page is completed (creating HttpWebRequest for ASP.NET and waving for PHP). Although this page is being processed, all other requests to this virtual host from one browser are not processed (even if I use different browsers from the same machine). I use two pages written in PHP and C #.

I tested Apache + PHP in mod_php and fast_cgi modes on Windows and Debian. For ASP.NET, I use IIS6 (with a dedicated application pool for this site and the default application pool) and IIS7 in integrated mode.

I know that it is better to use asynchronous calls for such things, but I'm just wondering why one page blocks the entire site, and not just the thread that processes the request?

Thanks in advance!

+1
source share
5 answers

It seems you are opening a standard php session that is open until the end of the request. This means that the session file is locked. Use session_write_close () as soon as possible if you no longer need session data.

+1
source

I do not think this blocks the site; I would suspect that an open connection blocks the client from executing more requests. Have you proven that other machines cannot use the site while your long-term request is being fulfilled?

0
source

If you see only one request coming into the application, the only thing I can imagine is a global lock somewhere in the pipeline.

The lock can be explicit (you wrote the lock statement) or implicit. If you see several requests, this may be due to the exhaustion of the thread pool.

Keep in mind that in addition to limiting the number of threads used to process incoming web requests, there is a separate cap for the number of simultaneous outgoing web requests through HttpWebRequest, and by default this limit is very low - if I remember correctly 2 per processor. I do not remember the parameter name in the web.config file, but try to find it.

In any case, the publication code will give us a better chance to help you.

0
source

I definitely noticed this behavior when debugging ASP.NET applications, but I always thought this was a problem with debugging configuration. Are you building everything in release mode and disable debugging in your web.config?

0
source

ASP.NET applications have a global session lock.

Use EnableSessionState="ReadOnly" for WebForms or [SessionState(SessionStateBehavior.ReadOnly)] for MVC. This will prevent blocking (of course, you cannot write anything in a read-only session).

I just found out why all ASP.Net sites are slow, and I'm trying to decide what to do with it.

0
source

Source: https://habr.com/ru/post/924553/


All Articles