Embedded High-level Interpretive Languages in Servers
- 0 Comments
Embedded Interpreters: A Historical Background
To avoid some of the problems of proprietary APIs and server-side includes, several vendors have turned to using embedded high-level interpretive languages in their servers. Embedded interpreters often come with CGI emulation layers, allowing script files to be executed directly by the server without the overhead of invoking separate processes. An embedded interpreter also eliminates the need to make dramatic changes to the server software itself. In many cases an embedded interpreter provides a smooth path for speeding up CGI scripts because little or no source code modification is necessary.
Examples of embedded interpreters include mod_pyapache, which embeds a Python interpreter. When a Python script is requested, the latency between loading the script and running it is dramatically reduced because the interpreter is already in memory. A similar module exists for the TCL language.
Sun Microsystems‘ “servlet” API provides a standard way for web servers to run small programs written in the Java programming language. Depending on the implementation, a portion of the Java runtime system may be embedded in the web server or the web server itself may be written in Java. Apache’s servlet system uses co-processes rather than an embedded interpreter. These implementations all avoid the overhead of launching a new external process for each request.
I will talk more about mod_perl, an Apache module that embeds the Perl interpreter in the server. However, as we shall see, mod_perl goes well beyond providing an emulation layer for CGI scripts to give programmers complete access to the Apache API.