Home » Developing U++ » U++ Developers corner » SCGI Class
SCGI Class [message #28120] |
Tue, 17 August 2010 16:35 |
jeremy_c
Messages: 175 Registered: August 2007 Location: Ohio, USA
|
Experienced Member |
|
|
I have created a SCGI class. SCGI is a more simple FastCGI interface. It allows the application to persist between connections, thus respond very quick unlike a CGI program that has to be loaded, initialized, executed and closed for each request.
This really comes in handy when there are expensive start up costs such as a database connection.
An example application:
#include <SCGI/SCGI.h>
class HelloWebApp : public ScgiServer {
public:
HelloWebApp() : ScgiServer(8787)
{
WhenRequest = HandleRequest;
}
void HandleRequest()
{
clientSocket.Write("Content-Type: text/plain\r\n\r\n");
clientSocket.Write(Format("Hello, %s!", query["NAME"]));
}
};
CONSOLE_APP_MAIN
{
HelloWebApp app;
app.Run();
}
There are other callbacks such as WhenAccepted, WhenClosed. "query" is public and is an instance of HttpQuery that is automatically populated. "map" is a VectorMap<String,String> that is also automatically populated with the server variables that are passed such as REQUEST_URI, SERVER_NAME, etc...
On my NetBook (1.6ghz Atom) the above SCGI app runs ~1200 requests a second. A static hello.txt file is ~1900 requests a second.
I still have a few loose ends to wrap up (post form data, some more general testing) but wondering if anyone else would find this useful and how to share it?
Oh... most web servers (Apache included) have a "mod_scgi" to interface with this type of application. The applications need not reside on the same computer as the web server, thus they can be distributed and offer load balancing. Advanced servers like Apache can do load balancing themselves internally knowing which SCGI app is in use and which one is not.
For anyone who wants to know more about the SCGI protocol: http://python.ca/scgi/protocol.txt
Jeremy
[Updated on: Tue, 17 August 2010 16:37] Report message to a moderator
|
|
|
|
|
SCGI Class
By: jeremy_c on Tue, 17 August 2010 16:35
|
|
|
Re: SCGI Class
By: zsolt on Wed, 18 August 2010 17:50
|
|
|
Re: SCGI Class
By: jeremy_c on Thu, 19 August 2010 15:32
|
|
|
Re: SCGI Class
By: mirek on Sun, 03 October 2010 20:19
|
|
|
Re: SCGI Class
By: jeremy_c on Mon, 04 October 2010 18:52
|
|
|
Re: SCGI Class
By: mirek on Mon, 04 October 2010 19:12
|
|
|
Re: SCGI Class
By: jeremy_c on Mon, 04 October 2010 19:19
|
|
|
Re: SCGI Class
By: mirek on Mon, 04 October 2010 20:28
|
|
|
Re: SCGI Class
By: jeremy_c on Mon, 04 October 2010 23:54
|
|
|
Re: SCGI Class
By: mirek on Tue, 05 October 2010 00:14
|
|
|
Re: SCGI Class
By: jeremy_c on Tue, 05 October 2010 00:30
|
|
|
Re: SCGI Class
By: mdelfede on Thu, 07 October 2010 17:40
|
|
|
Re: SCGI Class
By: jeremy_c on Fri, 08 October 2010 14:14
|
|
|
Re: SCGI Class
By: mdelfede on Fri, 08 October 2010 15:57
|
|
|
Re: SCGI Class
|
|
|
Re: SCGI Class
By: zsolt on Wed, 16 March 2011 22:06
|
|
|
Re: SCGI Class
|
|
|
Re: SCGI Class
|
|
|
Re: SCGI Class
|
|
|
Re: SCGI Class
By: mirek on Fri, 25 March 2011 18:25
|
|
|
Re: SCGI Class
By: zsolt on Fri, 25 March 2011 22:55
|
|
|
Re: SCGI Class
By: mirek on Fri, 25 March 2011 23:56
|
|
|
Re: SCGI Class
|
|
|
Re: SCGI Class
|
|
|
Re: SCGI Class
By: mirek on Sun, 27 March 2011 09:59
|
|
|
Re: SCGI Class
By: mirek on Sun, 27 March 2011 10:02
|
|
|
Re: SCGI Class
By: zsolt on Sun, 27 March 2011 22:51
|
|
|
Re: SCGI Class
By: mirek on Mon, 28 March 2011 08:54
|
|
|
Re: SCGI Class
By: zsolt on Tue, 29 March 2011 21:27
|
|
|
Re: SCGI Class
By: mdelfede on Sat, 11 February 2012 19:34
|
Goto Forum:
Current Time: Wed Jun 05 08:02:13 CEST 2024
Total time taken to generate the page: 0.01830 seconds
|