My confusion is, if thousands of requests come in for a particular servlet, then all those processes will be created in application server putting pressure on application server resources. That means problem has moved from web server to application server. How does it solve the problem ?

Often times an application server will be written to use threads instead of processes because of exactly the problem that you describe. But this is only one of the many benefits of moving away from such antiquated technologies as CGI.

When using vanilla CGI and perl, the following things to happen when the CGI script is invoked; load the perl interpreter, parse the code, load any modules used, connection to any databases and then execute the code. If you use an app server or even something as simple as FastCGI you can pre-load the perl interpreter, your code and any modules you are using as well as pool database connections. This means that for each web request you are just simply running your main code, nothing else. This is not only a CPU savings, but it is also a memory savings.

A decent app server may also provide other nice things such as hot-code reloading (loading in new code without server restart), ability to run multiple versions of code simultaneously, in process debugging or REPL (read-eval-print-loop) and more.

You are correct in saying that this means the "problem has moved from web server to application server", but this is a good thing. With CGI, you are 100% in control of your particular process and it is completely isolated, this is fine for quick and dirty solutions that aren't going to grow. But as soon as you move beyond this to a larger and more complex web application (if this were Java I would be calling it "enterprise"), the benefits of having pre-compiled modules and pooled database connections is much more obvious. It is at this point that you want an app server that has already figured out these hard details for you so that you can focus on writing your app and not basic plumbing.

-stvn

In reply to Re: instances of CGI in web server by stvn
in thread instances of CGI in web server by shahzama

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.