Web application is an application that executes based on web. We access to websites using web browsers like Internet Explorer and Firefox and web browser shows the website. By entering sentences like ‘http://www.google.com’ to web browser, we request web application to do so. Then web application creates a result corresponding to the request and send it back to web browser.
In order to provide what web browser requests, we usually need web server, application server, and data base.
- Web server
- Receive request from web browser, and send appropriate result to web browser.
- If it needs program to handle it, it uses application server or call program directly to create right result.
- Often used when providing HTML, image, CSS, Java Script files.
- Apache, ngnix
- Application server
- Handles something like log-in, list of posts and send it back to web server
- Data base
- Stores datas web application needs such as member informations, blog posts data..
- Oracle, MySQL, MSSQL
- Web Browser
- Request service execution to web server, and shows the result to users.
- Internet Explorer, Google Chrome, Fire Fox
Here is a brief graph explaining relations!
http://www-01.ibm.com/support/knowledgecenter/SSAW57_8.0.0/com.ibm.websphere.nd.doc/info/ae/ae/tins_webplugins_remotesa.html
Application server can also provide HTML, CSS, image, but the reason why web server provides images and application server provides program is performance. Generally, web server like Apache is well focused on providing HTML & CSS and application server like Tomcat & Jboss does a good job of providing result using JSP, Servlet.
CGI & Application server
To summarize, web browser first request service to web server, and web server send back the right data using web application program. We can say there are two different types of web application depending on how web server run web application programs.
1. CGI method
2. Application server method
What is CGI?
“Abbreviation of Common Gateway Interface, CGI is a specification for transferring information between a World Wide Web server and a CGI program. A CGI program is any program designed to accept and return data that conforms to the CGI specification. The program could be written in any programming language, including C, Perl,Java, or Visual Basic.” (webopedia).
Basically, it is a specification for transferring information between web server and program.
The difference between CGI and application server is whether web server directly call the program.
<How CGI works>
request -> web server -> (directly calling) perl program
-> (directly calling c program
When web browser request web server to execute program, web server directly calls CGI program written in perl or C, and send them back to the web browser.
If the address ends with cgi like http://www.some.com/somepath/mt.cgi, it means that website used CGI method.
<How application server works>
Rather than calling program directly, it indirectly executes web application program using web application server.
request -> web server -> application server -> program1
-> program 2
In this method, application server transfer the result to web server and web server transfer it back to web browser. Most web application uses this method.
*Application server method is preferred when a lot of people connect to this website.
Let’s say, N web browsers requested same program. CGI will load N programs, which means if the number of web browsers connected at the same time increases, memory required to execute program will increase proportionally. This will slow the program loading time.
On contrary, application server calls program only once, regardless of the number of web browsers connected at the same time. This means less memory uses.
Then, this way is much more efficient to handle portal with large traffic!