Closed‑Loop Architecture Practices for JD Product Detail Page Service

This article shares detailed, still‑relevant architectural practices from a 2015 internal JD training PPT, covering service monitoring gaps, stateless design, Nginx + Lua caching, Twemproxy‑Redis sharding, connection management, timeout settings, upstream strategies, Java/Tomcat tuning, and other performance‑optimizing techniques for high‑concurrency e‑commerce systems.

JD Tech
JD Tech
JD Tech
Closed‑Loop Architecture Practices for JD Product Detail Page Service

The article presents unpublished details from the "JD Product Detail Page Service Closed‑Loop Practice" PPT, originally used for internal training in 2015, which remain applicable to current system architecture design.

Problems identified in the product detail page service:

Service quality lacks monitoring data.

Issues cannot be degraded in time.

API calls are scattered across departments.

Domain name resolution duplication prevents long‑connection benefits.

Overall architectural principles (Section 1):

Stateless design.

Use nginx+lua+tomcat7 stack.

Leverage local caches (proxy_cache, shared_dict, Guava cache).

Employ localtwemproxy for Redis sharding with cache separation.

Separate thread pools for core and non‑core business, with monitoring and switches.

Asynchronous updates.

Redis cluster in master‑slave mode.

Use Unix domain sockets to reduce connection count.

Enable keep‑alive long connections.

Provide configurable switches, cache TTL, fallback mechanisms, and exponential/random recovery.

Twemproxy + Redis (Section 2):

Use localtwemproxy for Redis sharding and cache separation.

Consider using HashTag and set maxmemory-policy allkeys‑lru with maxmemory‑samples 10.

Nginx keepalive (Section 3):

Enable long connections and limit their number.

Nginx timeout (Section 4):

Configure appropriate timeout values.

Nginx proxy cache (Section 5):

Use an in‑memory file system for proxy cache.

Be aware that response headers affect cache duration.

Parameters of caching can also be set directly in the response header. This has higher priority than the caching‑time directive. The “X‑Accel‑Expires” header sets caching time in seconds; a zero value disables caching. If the value starts with “@”, it specifies an absolute epoch time. If “X‑Accel‑Expires” is absent, caching can be controlled via “Expires” or “Cache‑Control”. Responses containing “Set‑Cookie” or “Vary: *” will not be cached.

Nginx DNS (Section 6):

Use local DNS resolution during proxy_pass.

Multiple servers may be resolved (nslookup) and Nginx Plus supports dynamic upstream resolution.

Nginx upstream (Section 8):

Enable upstream health checks.

Use ip_hash or consistent hashing strategies.

Example Lua code for consistent hashing:

local newval, err = ip_log:incr(ip, 1)
local toDelay = false
if newval > 50 then
    toDelay = true
    ngx_var.consistent_key = ngx_var.consistent_key .. '_' .. newval
    -- must run before set_uri
end

Nginx Gzip (Section 7):

Configure gzip_comp_level, gzip_min_length, and gzip_types as needed.

Nginx Real IP, client header limits, and request limiting (Sections 9‑11):

Set real‑IP handling.

Restrict request header/body size when proxying.

Apply request, connection, and rate limits; use IP/UA whitelists/blacklists; token‑based rate limiting; token‑bucket algorithms (Java Guava); delay throttling.

Reference articles on high‑concurrency rate‑limiting techniques are provided.

Nginx + Lua shared_dict (Section 12):

Use shared dictionaries as local caches.

Nginx + Lua API aggregation (Section 13):

Use a method parameter to indicate which backend service to call.

Pre‑filter illegal requests (e.g., XSS) with 403 responses.

Encapsulate call logic to improve cache hit rate.

Combine sub‑requests via ngx.location.capture_multi, cache only atomic interfaces, and retry or log via a proxy layer.

Nginx + Lua logging (Section 14):

Logging can be enhanced through custom Lua scripts.

Java architecture (Section 15):

Adopt asynchronous, non‑blocking event models (Servlet 3, Tomcat 7, Jetty 8).

Separate request parsing (Tomcat thread pool) from business processing (custom thread pools) to avoid bottlenecks.

Example start.sh JVM options:

export JAVA_OPTS="-Djava.library.path=/usr/local/lib -server -XX:-UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection -XX:CMSInitiatingOccupancyFraction=80 -XX:+CMSParallelRemarkEnabled -XX:SoftRefLRUPolicyMSPerMB=0 -XX:MaxDirectMemorySize=512m -Xss256k -XX:NewRatio=1 -XX:SurvivorRatio=6 -Xms16384m -Xmx16384m -XX:MaxPermSize=256m -Djava.awt.headless=true -Dsun.net.client.defaultConnectTimeout=60000 -Dsun.net.client.defaultReadTimeout=60000 -Djmagick.systemclassloader=no -Dnetworkaddress.cache.ttl=300 -Dsun.net.inetaddr.ttl=300 -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=$CATALINA_BASE/logs -XX:ErrorFile=$CATALINA_BASE/logs/java_error_%p.log"

Key server.xml connector settings (Tomcat 7 example):

<Connector port="1601" asyncTimeout="10000" acceptCount="10240" maxConnections="10240" acceptorThreadCount="1" minSpareThreads="5" maxThreads="5" redirectPort="8443" processorCache="1024" URIEncoding="UTF-8" protocol="org.apache.coyote.http11.Http11NioProtocol" enableLookups="false"/>

Important parameters: acceptCount, maxThreads, minSpareThreads, processorCache, acceptorThreadCount, pollerThreadCount.

Additional Java sections cover Servlet 3 asynchronous support, thread‑pool concurrency, asynchronous cache updates, Guava local cache usage, batch‑interface caching strategy, and other performance tips such as CPU binding, reducing connections, using memory file systems, large memory or enterprise SSDs, and full elastic‑cloud deployment.

Download the PPT at https://pan.baidu.com/s/1K-Djkf6IFZ7qSEIlNqYPAw .

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Backend ArchitectureTomcat
JD Tech
Written by

JD Tech

Official JD technology sharing platform. All the cutting‑edge JD tech, innovative insights, and open‑source solutions you’re looking for, all in one place.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.