C/C++ the language of future Web Servers?

Modern web servers have monster-like hardware, data centers crunching numbers at great speeds! But still the model languages for server side processing has been PHP, JSP, etc. No doubt these have been providing a great service to mankind by processing the back end data in the servers!

But still thinking about it, many of these languages apart from their awesome speeds and features that they provide have an inherent drawback – they are interpreted on the runtime! This very fact makes them much slower when compared to any other language like C or C++. Yes, they cannot be used on the server pages but still looking at this situation – you have a very large database of say 500 million words and your program needs to perform some complicated computations to shortlist a very few words based on some specific criteria. The very fact that languages like PHP are interpreted could reduce the rate at which your data is processed. Whereas any language like C/C++ with highly optimised algorithms and data structures could perhaps give us the result in a very very short time.

Now imagine if you could do this from a web server. A user on the client side submits some data and needs some result processed on the basis of that. But instead of processing that code in PHP or something we get that done by a compiled C/C++ program. Yes, this kind of mechanism can be used to power large data centers that can process very large amounts of data within a very few seconds!

A very simple model to do this could be as follows:

A user on the client side submits some data to a PHP page on the server. Now the PHP command does nothing but calls an executable program on the server, our compiled program in C/C++ and passes the user given input to that program. Now what that program does is compute the necessary results from the input rather than getting it done by our PHP code. So what we get over here is speed in processing that comes from a compiled C program that is directly being executed by the OS, rather than being interpreted. After the job of intensive processing has been done, we can now let the PHP file gather the results which will then just be displayed to the user on the client side.

This procedure will be quite efficient, but the problem is that our PHP code calls the C program. That requires a bit of time a bit of memory overheads for an extra running process.

But perhaps if we could write our own HTTP server in a C/C++ code that intercepts the data that the client submitted to the server and instead of calling another program altogether, we just call the function that would be required for intensive processing. This way we will be saving on time and processor overheads because there would be extra program to be called, it would will execute within the same server’s program!

This way we could write some efficient server, that processes large volumes of data in very short span of time!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s