views:

183

answers:

7

I was inspired by Slashdot, I was heard that it uses very limited servers to support a lot of users with fast response. And there is a website named slashcode, not sure if slashdot uses its source code.

I am wondering if Perl is the best to write a high performance web page? I know using Apache or IIS will be having a lot of overhead?

Any idea, books, papers, tutorials?

Thanks.

A: 

This post on serverfault suggestst that you could write an extension module to nginx for serving dynamic content.

Such modules need to be compiled to native machine code, so most likely are faster than running Perl.

Andre Holzner
Thanks, but some sort I don't want to use C/C++ to write the webpage, python may be preferred... Looks web.py good ?
Bin Chen
+2  A: 

Regardless of how fast your code is, at some point the bottleneck will stop being your code, and start being the web server itself.

Ignacio Vazquez-Abrams
+2  A: 

As long as you're not using the CGI interface[1] to talk to the web server, the language isn't going to have a noticeable impact on performance in 99% of cases. The exceptions are those in which you're doing heavy back-end processing rather than simply grabbing something out of a database, lightly massaging it, and sending it off to the user - and, if you are doing that kind of thing, you're likely better off doing it asynchronously if possible and stuffing the results into a database to be lightly massaged and viewed later.

The reason is, quite simply, that network connection and data transfer times will be so much longer than your program's execution time that it's not even funny. If it's taking 2 seconds to establish a network connection to the server and do the data transmission in each direction, nobody is going to care whether the processing on the server adds 0.1s or 0.2s on top of that 2s of network activity.

[1] Note that I am talking here about the vanilla CGI "start up a new process to service each incoming request" model, not the Perl CGI module (CGI.pm/use CGI). There are ways to use CGI while also making use of a long-lived process which handles multiple requests over its lifetime.

Dave Sherohman
A: 

Architecture and system design are more important than language choice for a high traffic app.

But selecting a language is not the first thing you should do, unless you are planning to write everything from the ground up.

You should be selecting a toolset.

If you want to have something soonest, look at existing web applications. What meets your needs? How customizable is it? Does it meet your performance/scalability requirements? If so, the language you use will be the language your app uses.

If you can't find a good match in existing apps, look at different frameworks, Catalyst, Rails, Squatting, Camping, Jifty, Django. There's a nice list of them on Wikipedia.

You should be able to find a framework that will do the job, many of them. Pick some contenders and choose one. The language you use will be the language your framework uses.

daotoad
A: 

I don't believe it would be faster than other common choices such as PHP, Python, Ruby, Java, or C#.

Mark Snidovich
mod_perl allows very tight integration with Apache (your program becomes a subroutine inside Apache), so it may be faster.
Alexandr Ciornii
@Alexandr Ciornii wow, thanks for the downvote. But, there's no evidence that Perl is any higher performance than PHP, Python, Perl, etc on Apache.
Mark Snidovich
+9  A: 

I'm going to assume that by "high performance" you mean both in the real time taken to produce a page and also how many it can serve concurrently.

The programming language isn't so important as your servers and algorithms. You may want to look into The C10k Problem which is a series of new technologies and refinement of techniques with the aim to allow a single web server to concurrently handle more than 10,000 concurrent connections. Things like the Nginx and lighttpd web servers and varnish cache came out of this project.

Big wins come from using a very light, very fast, very modular web server (Apache and IIS ain't it) with a very light, very fast cache in front of it to avoid having to process the same thing twice. For a high concurrency server, even caching for a few seconds can save you hundreds or thousands of processes. By chopping up a static page into a series of AJAX requests you can cache the more static bits and pieces independently of the bits that change frequently.

Instead of using mod_blah that embeds your program into a web server, use FastCGI or similar that puts your programs into their own little application servers. This allows them to run independent of the web server, possibly on remote machines and with load balancing. This lets you easily scale your processing power.

Eventually you're going to micro-optimize really important bits of your application code to the point where the language matters, but you can focus on the really important bits rather than having to do the whole project solely according to raw performance.

Schwern
+1  A: 

There's really no such thing as a "high performance page". That's like asking what the fastest car is (and if you watch enough Top Gear, you know that's not a simple answer). You have to think about what you actually want to do (i.e. the particular task), what you have to do to make that happen, and which tools would work best for that.

Are you going to have a lot of people doing a lot of small things, or fewer people doing really big things? Is it all going to happen at once (i.e. spikes), or is it going to be constant demand? Are you send back small chunks of data or serving up really large files?

Suppose that every portion were as fast as possible. It's a fantasy for sure, but consider it anyway. Now that everything is fast as possible, rank every part according to how relatively fast they are. What's the slowest part? Is it disk access? Network IO? Socket availability?

If you aren't at the point where you're already thinking about this, the language probably isn't that important beyond your skill with it.

There are a lot of books on web performance out there. :)

brian d foy