mysqltomcatapache2varnishweb-architecture

What is a common web architecture for java apps?


Im currently developing a java web application, and im researching how i should combine different types of technology in order to get the most use of a single webserver.

My plan so far is to have the following architecture setup

Internet ->
Varnish (reverse proxy) ->
Apache2 (mod_pagespeed, mod_jk) -> 
Ehcache-web (caching html page fragments,spring-cache) ->
Tomcat (java appsrv) ->
Ehcache (cache layer) -> 
MySQL (persistance layer)

Is there any problems with this design? What about scaling and clustering when it comes to that? Is there any other (better) solutions?

Thanks!


Solution

  • I do not envision a webapp in a traditional manner - but in terms of service providers and consumers. At work we've a RESTful API layer running under Tomcat, built by implementing Shindig interfaces. The layer interacts with MySQL as well as MongoDB. We have near/far caching using Memcached, which we plan to move to Redis given that we use a lot of list and set based operations. This layer also interfaces with Twitter and Facebook for certain APIs (like pushing out the status updates). All the endpoints are accessible as OpenSocial compliant REST/XML calls. We use NewRelic to monitor the service performance and SLA. Currently we're doing a little over 30K RPM with a response time of 10ms. We have a cluster of 4 Tomcats, 3 memcacheds, 3 MySQL (1M 2S) and 3 MongoDB (replicaset). All of the stack runs on Virtual Machines hosted by XenServer, running Centos. We use RabbitMQ for messaging/async operations like sending notifications out or talking to 3rd parties (Twitter/Facebook) so as to not block the VM threads. We plan to move to HornetQ+Scala Actors in the near future as the platform gets popular. The search runs on Solr but we're actively migrating to ElasticSearch.

    We architected the system in this API/Services based model so that we can serve more than one client platform. So when our Mobile app launches, that can re-use the APIs instead of having a separate set of the same stack for Mobile. This architecture abstracts the back-end offerings with no coupling to the front end. The front end we have is built in PHP/Zend, and it uses JQuery extensively. We are building a mobile front-end using HTML5, Phonegap and Sencha touch.

    For security we have open GETs but the writes are secured via 2-legged oauth. We will need to provide 3-legged oauth once we open up the API to external consumers and app developers.

    I hope this summary helps. Please do not hesitate to comment if you need further information or have any questions.