Wednesday, July 4, 2012

Differences between CGI and Servlet


<<Previous                                                                               Next>>

CGI
Servlet

It is a process based. i.e., for every request, a new process will be created and that process is responsible to generate required response.


It is thread based. i.e., for every request new thread will be created and that thread is responsible to generate required response.

Creation and destruction of new process for every request is costly, if the number of requests increases then the performance of the system goes down. Hence CGI technology fails to deliver scalable applications.


Creation and destruction of a new thread for every request is not costly, hence if the number of requests increases there is no change in response time.  Due to this, servlet technology succeeds to deliver scalable applications.


Two processes never share common address space. Hence there is no chance of occurring concurrence problems in CGI


All the threads shares the same address space, Hence concurrence problem is very common in servlets.

We can write CGI program in variety of languages, But most popular language is perl.


We can write servlets only in java.

Most of the CGI languages are not object oriented.  Hence we miss the benefits of oops.


Java language itself is object oriented.  Hence we can get all the key benefits of oops.

Most of CGI languages are platform dependent.


Java language is platform independent.



Fast CGI:
                                It improves the performance when compared with traditional CGI. In this case we have to maintain a pool of processes.  So that single process can serve multiple requests one by one.  The improvement is not up to the mark.  Hence it fails to deliver scalable applications.

1 comment: