Switchquery: High‑Performance Mobile Configuration Platform with Second‑Level Real‑Time Reach
Switchquery is a high‑performance mobile configuration delivery platform that achieves second‑level real‑time updates through a novel header‑based versioning scheme, eliminating push notifications and long‑lived connections while supporting Android, iOS, and hybrid clients with low cost and high reliability.
Switchquery is a high‑performance mobile configuration platform designed for scenarios that require sub‑second configuration updates. It provides a second‑level real‑time reach capability by embedding a version identifier in the HTTP response header (x‑switch‑config) and letting the client pull the latest configuration when a version change is detected.
Background : Mobile apps increasingly need rapid feature toggling, gray releases, and emergency rollbacks. Traditional push notifications suffer from low permission rates, while TCP/WebSocket connections consume server resources, and polling generates unnecessary traffic.
Technical Principle : The platform uses MCube to cache templates, loads them into a view‑tree, resolves expressions and events, and finally renders the UI. For configuration delivery, the server writes a new version number to a unified gateway; every client request passes through this gateway, which adds the x‑switch‑config header. Clients compare the version with their local cache and, if newer, request the configuration JSON from Switchquery.
Real‑Time Delivery Options considered were push messages, long‑lived TCP/WebSocket connections, and polling. All were rejected due to low reachability, high resource consumption, or excessive network traffic.
Chosen Solution : A header‑based versioning approach that requires no push permission, no long‑lived connections, and incurs minimal overhead. The flow is illustrated in the diagram (Fig 1). The steps are:
Users configure switches in the Switchquery CMS (boolean, integer, string, etc.).
The CMS writes a new version number to the unified gateway; the gateway stores the version in memory and writes a static JSON to CDN for fallback.
All client HTTP responses include the x‑switch‑config header with fields: switch flag, version, random delay, and reserved.
The client component receives the header, parses it, and if the version is newer, waits a random delay (to smooth traffic) before pulling the new configuration.
If the server is unavailable, the client falls back to the CDN copy.
Optimization : Configuration changes are aggregated over a configurable interval (default 5 s) to reduce gateway load; random delay spreads request spikes; in‑memory caching and CDN fallback improve stability during high‑traffic events.
Integration Process :
Android usage example:
//chName: switch name, returns defValue on failure
SwitchQueryFetcher.getSwitchBooleanValue(String switchName, boolean defValue);
SwitchQueryFetcher.getSwitchIntValue(String switchName, int defValue);
SwitchQueryFetcher.getSwitchStringValue(String switchName, String defValue);iOS usage example:
// Boolean switch, returns NO if not found
BOOL JDSwitchBoolValue(NSString *key);
// Integer switch, returns 0 if not found
NSInteger JDSwitchIntValue(NSString *key);
// String switch, returns nil if not found
NSString* JDSwitchStringValue(NSString *key);
// Example router calls for int, bool, string values
NSNumber *n1 = [JDRouter openURL:@"router://JDBSHServerConfigModule/intValue?key=test" arg:nil error:nil completion:nil];
NSNumber *n2 = [JDRouter openURL:@"router://JDBSHServerConfigModule/boolValue?key=test" arg:nil error:nil completion:nil];
NSString *n3 = [JDRouter openURL:@"router://JDBSHServerConfigModule/stringValue?key=test" arg:nil error:nil completion:nil];CMS Operations : Users create business modules, define switch metadata (ID, platform version range, system version range, type, name, rollout ratio, whitelist, value, description), and publish configurations. The UI screenshots (Fig 3‑4) illustrate module and switch creation.
Case Studies :
Project X (Spring Festival) : By delivering downgrade flags via Switchquery, startup API calls dropped from 110 to 8, achieving 100 % downgrade success with zero incidents.
Double Eleven 2022 : Switchquery served 38 business modules and 392 switches, reaching a 98.3 % delivery rate; configuration change QPS peaked 58.8 % lower than the previous year, ensuring stable promotion traffic.
Conclusion : Switchquery provides a low‑cost, high‑reliability, second‑level real‑time configuration delivery solution for mobile apps, supporting Android, iOS, H5, and RN clients, with future enhancements such as operation logs, device filtering, and dynamic whitelist management.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
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.
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.
