Design and Evolution of a Unified Exchange Mall Middleware Platform
The unified exchange mall middleware platform consolidates disparate points‑redemption and lottery flows into a four‑layer architecture—business, gameplay templates, domain models, and downstream services—offering standardized APIs, dynamic RPC routing, Redis‑based inventory control, anti‑fraud safeguards, and built‑in monitoring, thereby cutting development costs, enhancing maintainability, and ensuring system stability.
In the booming mobile internet era, apps adopt points exchange and lottery mechanisms to improve user acquisition and retention.
To improve reusability and stability, a unified exchange mall middleware was built to provide standardized points redemption and reward mechanisms for upstream services.
Background: Various growth activities (daily sign‑in, star forest, wish ocean, etc.) generated many independent redemption flows, leading to high development cost and inconsistent systems.
Business architecture: The platform is organized into four layers – upper‑level business (applications using the mall), gameplay sediment (templates using the Template pattern), domain models (activity, template, prize, inventory), and downstream dependencies (marketing, product aggregation, payout, etc.).
Gameplay iteration: The overall gameplay overview, RPC call optimization (1.0 using protobuf‑generated client/server code, 2.0 adopting SPI‑like dynamic routing), inventory design (simple daily/total stock to time‑slot stock with Redis and Lua scripts), prize horizontal iteration, anti‑fraud measures (business‑level frequency control, interface rate limiting, black‑list, token), and stability construction (monitoring, alerting, one‑click circuit‑breaker).
Key code snippets:
rest, err := redis.decr(key)
if err {
// ...
return err
}
if rest < 0 {
return limitErr
} # KEYS[1] = redis key
# ARGV[1] = pre‑computed remaining stock
local _args1 = ARGV[1]
local stock = redis.call('GET', KEYS[1])
if stock < _args1 then
return -1
else
local rest = redis.call('DECR', KEYS[1])
return rest
end
return -1Anti‑fraud strategy combines business‑level prize frequency limits, interface rate limiting via a flow‑control center, and black‑/gray‑list filtering with token verification for high‑value prizes.
Stability: Monitoring components, Prometheus SDK metrics, alert rules (pre‑warning, in‑process, post‑statistics) and a one‑click stop‑loss switch enable rapid response to anomalies.
Extensions: A visual H5 lottery component, integration with a growth task platform for point acquisition, and a simple points system completing the earn‑spend‑reward loop.
Conclusion: The exchange mall middleware provides a reusable, extensible backbone for various interactive features, reducing development cost, improving maintainability, and ensuring system stability.
DeWu Technology
A platform for sharing and discussing tech knowledge, guiding you toward the cloud of technology.
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.