How to design highly scalable web services in Java?
- by Kshitiz Sharma
I am creating some Web Services that would have 2000 concurrent users. The services are offered for free and are hence expected to get a large user base. In the future it may be required to scale up to 50,000 users.
There are already a few other questions that address the issue like -
Building highly scalable web services
However my requirements differ from the question above.
For example - My application does not have a user interface, so images, CSS, javascript are not an issue. It is in Java so suggestions like using HipHop to translate PHP to native code are useless.
Hence I decided to ask my question separately.
This is my project setup -
Rest based Web services using Apache CXF
Hibernate 3.0 (With relevant optimizations like lazy loading and custom HQL for tune up)
Tomcat 6.0
MySql 5.5
My questions are -
Are there alternatives to Mysql that offer better performance for what I'm trying to do?
What are some general things to abide by in order to scale a Java based web application? I am thinking of putting my Application in two tomcat instances with httpd redirecting the request to appropriate tomcat on basis of load. Is this the right approach?
Separate tomcat instances can help but then database becomes the bottleneck since both applications access the same database? I am a programmer not a Db Admin, how difficult would it be to cluster a Mysql database (or, to cluster whatever database offered as an alternative to 1)?
How effective are caching solutions like EHCache?
Any other general best practices?
Some clarifications -
Could you partition the data?
Yes we could but we're trying to avoid it. We need to run a lot of data mining algorithms and the design would evolve over time so we can't be sure what lines of partition should be there.