Backend Development 9 min read

DataVisor Risk‑Control Architecture and the Application of OpenResty

This article explains DataVisor's risk‑control system architecture, outlines the business challenges such as complex logic, massive data, high QPS and low latency, and demonstrates how OpenResty (Nginx + Lua) is used for high‑performance gateways, micro‑service style calls, hot‑loaded scripts, automatic circuit‑breakers, and progressive architectural evolution toward service‑mesh designs.

DataFunTalk
DataFunTalk
DataFunTalk
DataVisor Risk‑Control Architecture and the Application of OpenResty

The presentation introduces the speaker (DataVisor architect Zhao Xiaobiao) and outlines five key risk‑control pain points: complex business logic, huge historical data volumes, high QPS/TPS, strict latency requirements (50‑200 ms), and rapidly changing anti‑fraud strategies.

OpenResty, a high‑performance web platform built on Nginx and Lua, is presented as the core technology. Its advantages include fast development (Lua learning curve of 1‑2 days), performance close to C, dynamic script hot‑loading, low resource consumption per worker, and smooth garbage collection without stop‑the‑world pauses.

Performance metrics show typical p50 latency of 2‑3 ms and p90 of 5‑6 ms, confirming suitability for low‑latency risk‑control.

For complex query workloads, OpenResty’s capture (internal sub‑request) and cosocket (asynchronous TCP/UDP) mechanisms enable concurrent sub‑queries and external service calls, addressing high QPS and latency constraints.

Hot‑loaded Lua scripts allow rapid policy updates without restarting services, supporting gray‑release and offline data replay for testing new rules.

An automatic circuit‑breaker system integrates Prometheus, Alertmanager, and Grafana to detect abnormal interception rates, divert traffic to a safe “YesBox” instance, and recover within seconds.

The article compares monolithic versus micro‑service architectures, highlighting trade‑offs in debugging, startup time, deployment complexity, and scalability, and shows how DataVisor treats each business logic block as a lightweight micro‑service using OpenResty’s internal calls.

Horizontal and vertical partitioning strategies are discussed, emphasizing gateway reliability and isolation of business services.

Architecture evolution is illustrated across three versions: V1 (gateway, servers, DB, messaging), V2 (adds Pika, Kafka, analysis modules, horizontal/vertical scaling), and V3 (service‑mesh style with privileged sidecar agents and OpenResty‑based sidecars).

Finally, the speaker shares personal insights: a good architect must understand business, technology, and customers; focus on reduction rather than addition; and prioritize high performance, high availability, scalability, and low cost.

Performancebackend architectureMicroservicesService Meshrisk controlOpenResty
DataFunTalk
Written by

DataFunTalk

Dedicated to sharing and discussing big data and AI technology applications, aiming to empower a million data scientists. Regularly hosts live tech talks and curates articles on big data, recommendation/search algorithms, advertising algorithms, NLP, intelligent risk control, autonomous driving, and machine learning/deep learning.

0 followers
Reader feedback

How this landed with the community

login 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.