Scalability Thumb Rules for Programmers (2011)
less than 1 minute read
- Avoid Synchronization. Keep it short.
- Use lock-free data structures and those in java.util.concurrent.atomic
- Use Non-Blocking I/O java.nio package for high-scalability. Use only for very high throughput applications.
- Single thread tasks ARE a problem and would not scale on multiple CPUs. Use parallel execution.
- More memory mean more GC freeze time.
- SQL DB becomes the bottleneck ultimately. Work around this constraint.
- Synchronous logging is a seriois issue. Must avoid.
- No single point of Failure.
- Failover mechanism - by load balancers and automatic watchdog/recover scripts.
- JVM Caches (internal to JVM) should be read only. Use clustered caches instead with replication.
- Replicate sessions in real time (on the cluster/DB etc.)
- Keep session objects Serializable. A good practice is to enforce the use of a custom method like the addObjectToSession(String key, Serializable value) method, instead of the default HttpSession.setAttribute (String key, Object value) method when adding session data.
- Have application level failsafe.
- Use distributed cache that is scalable. Memcache, Terracota and Jboss cache are good examples.
- Use NoSQl or Bigtable like distributed databases such as Cassandra, MongoDB, Hypertable, CouchDB or HBase (for Hadoop)
Leave a Comment