Saturday, January 24, 2009

Running a web-server from home

So , you want to run a web-server from home (why? , for testing purposes, of course! , don`t deploy anything on home server. Your ISP will eventually block you...)

Behind a router:
1. Change tomcat back to port-80.
2. Assign a LAN static-ip to the web-server on the LAN.
3. configure your router to do port-forwarding on port 80 to your static-ip.
4. Use a dynamic-dns to map a domain into your ever-changing ISP provided ip address.
And you are ready to go.


Few resources:
Good ref (for MAC)
http://www.canyouseeme.org/ - external site which tests your open ports.
http://www.no-ip.com/ - dynamic-DNS (with free version for non-commercial usage)

Thursday, January 15, 2009

Web Servers

web-servers
Lots of buzz words are flying around when talking about web-servers. I assume you know what it is , and just want to find which of the free/commercial servers will better suit your need:


web-servers For PHP/CGI/Pyton (etc) developers

1. Apache HTTP server [ = HTTPd]- a C-based implementation of a web-server for which you can use modules with the well-known "script" languages: PHP , Perl , Pyton , Ruby.
2. NginX - 2nd generation server (faster,less known)A C-based implementation of web-server which allow you to use again the "Script" langugs. This is a rather new server with better io utilization which should outperforme the Apahce HTTP server.
3. Lighttpd - another 2nd generation server, less table than NginX.

web-servers For Java developers

1. Apache Tomcat - a JAva-based implementation of web-server for which you can write modules in Java (plain java servlets or JSP). The internal modules which support the servlets are called "catelina" and the JSP is called "jasper" , but these names are only important for knowning which log file to look. It is not related to the popular Apache-c-based-Http-server. ( they share the "Apache" prefix cause they come from the same open-source organization , but there are dozens of Apache projects which are not technology related to one another)
2. Jetty - a small webserver , usually used for web-applications which run on a very small scale ( some application need only to work only on the localhost , and Jetty is a good solution for them)
3. JRun
4. Resin

web-server for ASP.NET
Here, like in many microsoft applications, you have one and only one choice: IIS


Simple so far? lets make it bit more complex - Interconnections!!!!
On some sites, one web-server gets the original request and forward it to another web-server. Few milliseconds later , it gets the response and send it to the user.
In this setups it is possible that the "gateway" web-server will be a c-based one , and the other is java-based one. They will connect to each other in a different protocol (its a waste to use HTTP between two servers) .
For apache-http-server(c-based) to Apache-Tomcat(java-based) , the connector is using the AJP protocol. see The Apache Tomcat Connector - AJP Protocol Reference
http://tomcat.apache.org/connectors-doc/generic_howto/workers.html

Why using interconnections?
usually when the Apache(c-based) is the load-balancer and the Tomcat`s really to the dynamic-http generation.
Note that it is possible to run a web-app (pure java) of a load balancer on tomcat , but it (by rumers) does not get close to the Apache(c-based) performance at load balancing.





Performance Benchmarks


Between different web-server "languages"
It will be intersting to see which web server flavor (c-based, java-based or IIS) performs better in similiar tasks of static pages and similiar dynamic pages. Didn`t find a good comparison , but iI do do not see anyone chaning the implementation languge of his company site just because the other langugle web-server performance is better.

Inside java web-server
http://www.webperformanceinc.com/library/reports/ServletReport/index.html - bottom line is that Tomcat and Resin are close. 1000 concurrent users per second (when some have short sessions , some medium and some large -yes , it does not say much about the numbers in your site)
http://tomcat.apache.org/articles/performance.pdf
http://tomcat.apache.org/articles/benchmark_summary.pdf - static files (Tomcat VS apache-C-based-server)


conclusion
It`s hard to find reliable benchmark between all the web-server matrix. (There should be a "Tom`s Hardware" type of benchmark for web-servers)
That`s said , the actual server choices which are seem to be recommended.
  • Choose dynamic web-server , according to the language you are familiar with. If you use Java , the free Apache Tomcat should be great.
  • If you are not going to have a lot of static pages/images or load-balancing , you can use Tomcat for all the rest too.
  • Otherwise , Choose "static " web-server as one of the 2nd generation C-based servers. NginX is a good choice. Its probably better than the java based servers. You can also use its load balancing capability.
Final notes:

  • Look at the feature matrix of the servers you use. If you need advanced features (load balancing , proxing etc ) , your choice will be easier because the number of servers will be more limited.
  • Remeber to look for the bottlenecks: dynamic web-server usually uses a Database which tend to be the bottleneck. Static web-server bottleneck tend to be the bandwidth itself.