I am writing a Facebook application that would use a Postgres DB along with Facebook APIs and run on Amazon EC2. (and I am hoping for heavy loads )
With Java, I know that DB would be my primary bottleneck and concurrency limitations of Tomcat would be the secondary bottleneck. I could alleviate DB issues with caching and concurrency issues with horizontal scaling . ( but this would add to my EC2 costs).
How would Erlang or Haskell help in this situation ? ( assuming I am able to master the learning curve).
I’d take a look at http://www.highscalability.com and look at case studies of how to go about scaling your application to larger and larger loads. In particular search there for Brad Fitzpatrick’s description of how he scaled LiveJournal and Danga Interactive (eg, this 2005 presentation).
Your intuition about the database being the first bottleneck and then the web server is probably correct, but of course you need to measure.
The major ways to scale your site will involve clustering and caching and database sharding and so on. The choice of programming language is secondary, and generally affects the raw performance on each box. See Henderson’s Building Scalable Web Sites and Schlossnagle’s Scalable Internet Architectures for other ideas and background in this area.
Having said that, a functional language may help to improve your overall scalability. Twitter used Scala to improve back end performance. Scala is a JVM language that combines object-oriented and functional styles, supports the Actors concurrency model, and runs at nearly the speed of Java (Martin Odersky, the creator of Scala, also wrote the current Sun Java compiler). So if you should run into a concurrency bottleneck you might want to sprinkle a bit of Scala in with your Java.