Evolution of a Java Web E‑commerce System: From Single‑Server Deployment to Scalable Architecture
This article walks through the step‑by‑step evolution of a Java web e‑commerce platform, covering initial single‑machine deployment, server‑database separation, application clustering, load‑balancing techniques, read‑write splitting, caching, database sharding, service‑oriented architecture, and the introduction of messaging middleware to achieve a highly scalable and maintainable system.
We use a Java web e‑commerce example to illustrate how a simple system can evolve through multiple architectural stages.
Stage 1 – Single‑machine website : All components (Tomcat/Jetty, JSP/Servlet, Spring, MyBatis/Hibernate, MySQL/SQLServer/Oracle) run on one server.
Stage 2 – Separate application server and database : The web server and database are split onto different machines to improve load capacity and fault tolerance.
Stage 3 – Application server clustering : Multiple application servers are added behind a load balancer (e.g., keepalived + ipvsadm) to distribute traffic; common algorithms include round‑robin, weighted round‑robin, source‑hash, destination‑hash, least‑connections, weighted‑least‑connections, etc.
Stage 4 – Database read/write separation : Master‑slave replication or middleware (e.g., MyCAT) is used to separate read and write traffic, reducing load on the primary database.
Stage 5 – Search engine for read pressure : Introduce an inverted‑index search engine to handle heavy fuzzy queries (e.g., product title searches) that are inefficient with SQL LIKE.
Stage 6 – Caching layer : Apply application‑level caches (Guava, Memcached, Redis) and page caches (HTML5 localStorage, cookies) to reduce database reads.
Stage 7 – Database vertical and horizontal sharding : Split data by business domain (vertical) or split large tables across multiple databases (horizontal) using middleware such as MyCAT, handling routing, primary‑key generation, and pagination.
Stage 8 – Application splitting and service‑oriented architecture (SOA) : Decompose monolithic code into separate services (e.g., user, product, transaction) to avoid code duplication and improve maintainability.
Stage 9 – Message middleware : Introduce a language‑agnostic messaging system (e.g., Dubbo with Zookeeper) to enable reliable inter‑service communication, load‑balancing transparency, and monitoring.
Each stage presents specific challenges (load balancing, session consistency, data synchronization, routing, etc.) and proposes solutions, illustrating a practical roadmap for scaling a Java web application.
Top Architect
Top Architect focuses on sharing practical architecture knowledge, covering enterprise, system, website, large‑scale distributed, and high‑availability architectures, plus architecture adjustments using internet technologies. We welcome idea‑driven, sharing‑oriented architects to exchange and learn together.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.