16

I have a web application project where performances count more than anything else, and I have the choice of the technologies to use.

The language shootout benchmarks that are not really related to web applications.

What would you recommand as the best suitable candidates?

Thanks!


A friend suggested the gwan server on IRC. Looks to be what I was searching but I never heard about it before. Anybody with prior experience on this package? Ease of use, reliability?

Before I leave Apache, I would like to get your thoughts.

Gil
  • 3,279
  • 1
  • 15
  • 25
Michi
  • 169
  • 1
  • 1
  • 4
  • 1
    You are talking specifically about server-side programming? – Adam Crossland Aug 11 '10 at 14:19
  • 7
    Use your favorite server scripting language in the normal areas and do the performance critical stuff in C and call it from your script. – Amarghosh Aug 11 '10 at 14:19
  • 2
    not only is this subjective it also has several duplicates on SO, please use search. Oh, and specify your requirements more clearly if you want clear answers. – SpliFF Aug 11 '10 at 14:20
  • what kind of web application is it i.e. what kind of data / processing will it be doing? – Jagmag Aug 11 '10 at 14:21
  • 1
    Yes, that's server-side programming. And, no, I don't see performances as anything 'subjective'. Mostly, image processing and encyption will take place. – Michi Aug 11 '10 at 15:14
  • Related: http://stackoverflow.com/questions/3502896/does-anyone-has-first-hand-experience-with-g-wan-web-server – Benjol Aug 18 '10 at 11:59
  • So why exactly does it need to be scripting language? image processing and encryption do not sound like they benefit from dynamic nature of languages. But maybe you are asking which language has most efficient extension/featuers (usually written in C) to call to do such tasks? – StaxMan Jan 11 '11 at 18:04

9 Answers9

8

G-WAN is a neat webserver: it's based around the "C scripts" concept:

A C script is simply C source-code that is compiled by the webserver and then loaded in protected memory. It will get called by the webserver when a request to the servlet is made. The servlet, as it's compiled by a C compiler, is "as fast" as normally compiling a C program. However, the advantage of C scripts to, for instance, CGI or FastCGI, is that the compiled program is in the same memory space as the webserver. This reduces the overhead of communication (either by creating a process, in the case of CGI, for each request, or the socket for FastCGI).

The webserver is using the select/poll technique: non-blocking I/O. However, there's a neat thing to it. Every program can be written as if it was using blocking I/O. As the webserver itself compiles each C script, it can transform the program to use non-blocking I/O. As of this, it can link itself to third-party libraries (like database access) and still make use of the non-blocking I/O nature: no thread/process context switching.

The tools provided for programming the C scripts are, for instance, caching and safe buffers. The next (not yet released as of writing this post) version will also include a Key-Value store.

Performance-wise: there are some benchmarks available showing it's outperforming any other webserver, however I don't trust these. Try writing a small CPU intensive program in C and in, for instance, PHP. Let the C script run on G-WAN and the PHP script on Apache, and do a benchmark yourself.

There is more to it, but that's out of scope for this question.

Some downsides of G-WAN is that it is developed by only one person. There is a forum, however, where you can ask questions.

Ease of use is limited by your skill in C. The API provided, however, is simple. It still has some inconsistencies and (in my opinion) ugly parts, but that's not a problem. A more serious problem is that each version is not guaranteed to be backwards-compatible and you may have to rewrite.

If you want to be safe: make use of C's platform independentness: allow your code to be compiled to (Fast)CGI programs and also to be used by G-WAN. Might G-WAN fail, you can always fallback to Apache's (Fast)CGI (see http://www.fastcgi.com/ for API's).

Pindatjuh
  • 10,550
  • 1
  • 41
  • 68
  • 1
    There are **independent** benchmarks showing the same results so your trust has little to do with those facts: http://www.rootusers.com/web-server-performance-benchmark/ here Apache, Nginx, Lighttpd, Varnish, Litespeed, Cherokee and G-WAN are tested on 1/2/4/8 CPU Cores – Gil Oct 14 '12 at 09:38
7

If performance counts more than anything else, don't use a scripting language. Especially since you have full control over the technology stack. Compiled languages will perform better for CPU intensive operations.

marr75
  • 5,666
  • 1
  • 27
  • 41
  • 5
    or write a C (or other compiled language) extension library to some scripting language, to get the best of two worlds. – kriss Aug 11 '10 at 14:59
  • Scripts are a requirement because the source code of the web application must be constantly available for security purposes (allowing supervisors to check that no tampering took place from the inside or from the outside). – Michi Aug 11 '10 at 15:11
  • 6
    Michi, then, speed isn't the top priority really? You should be able to more or less validate the executables using a MD5-hash or something similar, which would allow your supervisors to check that no tampering took place. – Rob Aug 11 '10 at 16:18
  • 1
    @Michi: and if you do not follow the path suggested by @Rob (or some equivalenbt one), it will be really hard to ensure no tampering took place at the Web server modules level, or at the OS level (and a human supervisor reading source code is not an efficient way to check a file didn't changed anyway). Would they start reading application code every morning to check nothing was tampered with ? Sounds funny. – kriss Aug 11 '10 at 19:18
  • 1
    Rob's MD5 idea is a much better way to audit when the code files have changed, and in fact, compiled files would add another level of difficulty to changing the code. Overall, this seems like a pretty silly security requirement, and an even sillier way to handle it. If your supervisors are worried about the code being changed maliciously internally, they should setup a system that auto notifies them when files hashes change. – marr75 Aug 12 '10 at 14:18
4

LuaJit (Lua) is the fastest scripting language with JIT technology..

if you want the fastest for server side web application (that not always scripting), that would be g-wan.. you can use c, c++, java..

ASP.NET is also fast enough for almost anything, but quite pricey

php with hiphop would be easiest to learn and also fast enough..

it depends on how many request do you need.. and how fast you learn the language ^^ don't forget to cache static data (using memcache or nosql)

Kokizzu
  • 24,974
  • 37
  • 137
  • 233
3

Begin by identifying if your application performance really depends on the language or on some other factor (like database requests for instance). Ability to cache results can also be a very important factor.

For performance the language used come quite far in the list of important points to check and the use case also influence which language is better. For example if you have many regex to check you should check regex support in the candidate language, etc...

For image processing, the most important point will probably be the underlying image library you use, usually written in C. I have the case of ImageMagick in mind, because I'm currently using it. It's available for as a library for most languages and the scripting language layer is only necessary to call functions of the library and used language at that level won't change much (but caching precomputed result images could change performance by a large margin). This use case would probably be similar for calling a cryptographic lib.

If performance is really such an issue, for image processing you could also consider using a lib that works with GPU accelerator cards (libs with cuda or openGPU support).

kriss
  • 23,497
  • 17
  • 97
  • 116
  • Thanks but ImageMagick (a very feature-rich package) is way too big and not that fast. – Michi Aug 11 '10 at 15:12
  • 2
    @Michi: I'm not suggesting using it, just that most libs should have thin layers to access them from scripting languages, find the lib you need, check the layer is available. I hope you are not expecting to get better performance from image manipulation code written using some scripting language ? – kriss Aug 11 '10 at 15:50
  • In my experience, it really depends on who wrote the code: I see atrocious C code everywhere - letting other languages make ridiculous claims. – Gil Nov 15 '12 at 08:29
  • Yes, you are right. You can only compare things for similar programmer skill level. That is an important factor in the points to check before changing language : is it really slow or am I too dumb to use efficiently available tools. It is usually not a good move to change for a lesser mastered programming language. Chances to write a more efficient program this way are quite thin. – kriss Nov 15 '12 at 10:09
3

Javascript is constantly being scrutinized and optimized for use on mobile devices, so on actual full-size servers it runs EXTREMELY fast. Check out Node.JS, a project for implementing server side javascript to serve webpages: http://nodejs.org/

pokstad
  • 3,411
  • 3
  • 30
  • 39
2

Well, if you use a database with a large volume of data you will spend more time there than running a php or asp or (insert other flavours here) script
If you can you should build a mockup of your app (or at least a segment of the more database or processor-intensive parts) and try to benchmark those

vlad b.
  • 695
  • 5
  • 14
  • Thank you for the reply. In fact, database is not involved, only image processing and other CPU-intensive tasks like encryption. – Michi Aug 11 '10 at 14:48
  • Then i would compare language build-in functions versus running stuff from the command line, one at a time and in batches....

    For massive image parallel image processing i usualy have a small processing script that does all the work and a process manager that sets some limits on cpu/ram useage and spawns/pauses/stops processes to always work at the desired load with a 5% room for error.

    For slicing and md5-ing files i use a similar script and both can run at the same time and leave enough power for apache to work as fast as normal.
    – vlad b. Aug 12 '10 at 15:01
  • Even DB jobs can be accelerated by an app server acting as a cache. – Gil Oct 14 '12 at 09:40
-1

Update: Seem like Java 7 using NIO.2 has manage to outperform Gwan using C but almost 2x in timing, it is incredible but you can a few a simple tests.

The only downside of Java is not able to integrate shared libraries built on C. I'm ready to challenge someone to prove me wrong that Java NIO.2 is slower than C.

James ONG
  • 47
  • 1
  • 7
  • 1
    sure it is able to call c libraries. ever heard of [JNA](https://github.com/twall/jna) (or the even older [JNI](http://docs.oracle.com/javase/6/docs/technotes/guides/jni/index.html)) – mata May 03 '12 at 19:02
  • **Java NIO is much slower than G-WAN+Java**: http://gwan.ch/blog/20120809.html#hello.java – Gil Nov 15 '12 at 08:24
-3

The fasted scripting Language is ASP followed by PHP, but if you want applications that scale to unlimited speeds, use C++ or Java. Google Search uses C++ Gmail uses Java YouTube = Python Twiiter used to use Ruby now they shifted to Java Facebook = PHP at front end and some java at the backend

But i recommend PHP at the front end and C++ at the back-end

  • 3
    Could you please provide some benchmarks that supports your claims? Right now there is no way to check your remarks. – Paul Hiemstra May 03 '12 at 14:18
  • 1
    C#/Mono is slower than PHP... unless served by G-WAN: see http://gwan.ch/blog/20120923.html#loan.cs and http://gwan.ch/blog/20121021.html#hello.php – Gil Nov 15 '12 at 08:26
-3

I recommend the Java programming language; it's not a scripting language, but it's probably the fastest programming language that can be used for programming web applications. I also recommend using a framework like Spring for a better programming experience (versus "raw" Java Servlet Programming).

Mr. X
  • 23
  • 1
  • Hmm... my early (crude) tests show that Java is faster than C# - but slower than PHP for what I try to do. – Michi Aug 11 '10 at 15:09
  • 1
    Java is faster in some problem domains, some functions, some configurations but slower in others. Depends on java flavor and hardware match ups, too. For all intents and purposes, java and asp.net are on the same order of speed magnitude, PHP is definitely on a slower order of magnitude (although experiments with compiling scripting languages are having promising results). – marr75 Aug 11 '10 at 23:26
  • Generally Java is fast enough for most tasks. It is not slower than PHP for any task I know of, however, it is possible that PHP extensions (written in C) can be faster for some tasks. – StaxMan Jan 11 '11 at 18:06