IIS Server explanation

Freedom1989

Member
Joined
Mar 30, 2007
Messages
113
Reaction score
1
Can someone explain to me how IIS works. (In term of worker process, thread, atomic, or how iis server deal when 1 user or concurrent user make a request from browser)? I don't need code but I need some explanation and guide.



Currently, I am designing e-commerce project. I need to draw information from database and assign uniquely. What I unsure off whether IIS process 1 user request at a time. Or IIS can process multi user concurrently at such those concurrent user might draw same information and boom web application crash.

ps for my broke english and grammer :)
 

davidktw

Arch-Supremacy Member
Joined
Apr 15, 2010
Messages
13,547
Reaction score
1,301
Can someone explain to me how IIS works. (In term of worker process, thread, atomic, or how iis server deal when 1 user or concurrent user make a request from browser)? I don't need code but I need some explanation and guide.



Currently, I am designing e-commerce project. I need to draw information from database and assign uniquely. What I unsure off whether IIS process 1 user request at a time. Or IIS can process multi user concurrently at such those concurrent user might draw same information and boom web application crash.

ps for my broke english and grammer :)

I'm not a fan of Microsoft technologies, as such I will answer to my best capability for general web servers design pattern. My knowledge is basically in the Apache Web Server, Nginx and similar web servers. However even so IIS is not a new technology, as such shouldn't deviate much from the rest except those event base systems.

IIS is a multi-threaded web server in Microsoft platform. Like a multi-process or even multi-threaded Apache Web server, it can serve concurrently multiple requests made to the server.

Generally the design of a web server is the parent process/thread will listen to a designated TCP socket, primarily running on ports 80(HTTP) and/or 443(HTTPS). This parent process will block for incoming TCP connection. Once a connection is established, it will pass the socket to either another process or another thread for serving the request.

Below is a simple spawning new client process or thread to serve one client
18fig04.gif


Offloading each web request to the slave is how a generic TCP server makes it possible to multiple requests concurrently. The above is a very simple and naive approach and do not exactly explain how IIS does it internally.

But I'm pretty sure no one will ask you for the innards of IIS since it is a close source to start with, and I don't think it is of particularly high interest to a lecturer to ask for such details. So just answer from a generic multithreaded web server will suffice.

Access to the database is more tricky, it is not exactly the job of IIS, but rather the scripting language responsibility. Since IIS is a multithreaded web server, as such, there is likely not more than 1 ASP.NET engine running at any time. That is not true for multi process design for in unix systems. However each web request should have a different request context and the same ASP.NET engine will run each context differently in its own space.

Access to the database by the ASP.NET engine will depends on the driver you are using and what kind of databse you are accessing. Modern database will normally support connection pooling. In connection pooling, connections to the database are shared across multiple web requests one at a time. Since each pool will have multiple database connections, the connection pool system will manage these connections, allocating one at a time to web requests threads. Each thread must return the connection back to the pool after use and it will be given to another thread. Within each database connection, there is a notation of session. Within each session, there could be one or more database transactions.

It is the responsibility of the web application design to ensure shared resource management. Database transaction and locking mechanism will ensure consistent access most of the time, but it is ultimately the job of the web application to govern the consistency across the whole application.

Most likely it will not crash when shared data are not access properly with exclusiveness when required, but you will likely get inconsistent output.
 

Freedom1989

Member
Joined
Mar 30, 2007
Messages
113
Reaction score
1
Hi,

Just 1 question, If iis is multi-threading and we don't know how iis work internally. we can't assume that is likely not more than 1 ASP.NET engine running at any time. so there could be a chance different threading is performing the code at the same for different user?
 

davidktw

Arch-Supremacy Member
Joined
Apr 15, 2010
Messages
13,547
Reaction score
1,301
Hi,

Just 1 question, If iis is multi-threading and we don't know how iis work internally. we can't assume that is likely not more than 1 ASP.NET engine running at any time. so there could be a chance different threading is performing the code at the same for different user?

It is true, unless you are told exactly how IIS is designed or you managed to find such information online, it is not easy to make such assumption. However it should be possible to find out by testing if there exist more than one web requests handle by different thread ID and if this occurs very frequently. It could be possible that ASP.NET engine deal with concurrent scripting requests by spawning multiple threads and each thread is an engine by itself.

I think you need to discard the notion of user, there is no user to speak. Each user can be multiple web requests made when accessing a webpage. When multiple users can accessing, all these web requests from all users can be in any random order. The tracking for web requests are normally by cookies or sessions, but the web server don't really care when serving web requests except that the engine will know which user context it belongs to

Actually why is there a need for you to dig so deep ? Are you studying the innards of IIS ? It seems like your motive should be limited to understanding the web request life cycle, but doesn't need to know internally how IIS handles it.
 

mgx-alander

Greater Supremacy Member
Joined
Jan 19, 2008
Messages
97,736
Reaction score
15,145
what do you need to draw from the DB to assign uniquely? are you generating a primary key or joint key?

Each worker process keeps its own in-memory state. You would need some kind of out-of-process state management if you want to share data between processes.

(read about worker process here)

if you really dont want 2 threads to generate identical key i suggest that you manage DB connections via built-in MDAC connection pooling so that you can limit the number of connections in the pool to one, so no 2 users can access the database at the same time, but at your end you have to catch the exception and do a try again if that happens..
 
Last edited:

davidktw

Arch-Supremacy Member
Joined
Apr 15, 2010
Messages
13,547
Reaction score
1,301
what do you need to draw from the DB to assign uniquely? are you generating a primary key or joint key?

Each worker process keeps its own in-memory state. You would need some kind of out-of-process state management if you want to share data between processes.

if you really dont want 2 threads to generate identical key i suggest , I would suggest that you are best of managing database connections via built-in MDAC connection pooling, you can limit the number of connections in the pool to one, so no 2 users can access the database at the same time, but at your end you have to catch the exception and do a try again if that happens..

Generating unique keys is the database job, it doesn't require the web processes to coordinate. Different databases have different ways to solve this problem. Oracle for example uses Sequence
 

mgx-alander

Greater Supremacy Member
Joined
Jan 19, 2008
Messages
97,736
Reaction score
15,145
i know that

ms sql has autonumber

but he said

I need to draw information from database and assign uniquely.
so i really dont know wat he is doing
 

ykgoh

Master Member
Joined
Jan 1, 2000
Messages
2,782
Reaction score
0
-snip-
I need to draw information from database and assign uniquely. What I unsure off whether IIS process 1 user request at a time. Or IIS can process multi user concurrently at such those concurrent user might draw same information and boom web application crash.
-snip-

I think TS is referring to user sessions. When 2 or more users are accessing the web server at the same time and accessing some shared resources (e.g. common database), whether his web app can still run properly.

If a web server or database crashes because of concurrent multiple users, really dunno what to say. :s22: They are designed from the start to handle this.
 
Important Forum Advisory Note
This forum is moderated by volunteer moderators who will react only to members' feedback on posts. Moderators are not employees or representatives of HWZ Forums. Forum members and moderators are responsible for their own posts. Please refer to our Community Guidelines and Standards and Terms and Conditions for more information.
Top