A comprehensive guide to consolidating multi-layer Nginx into a single programmable OpenResty gateway, covering Lua request phases, shared-memory rate limiting algorithms (leaky bucket, token bucket, distributed), dynamic configuration, authentication ordering, risk control tiers, performance tuning, and six production troubleshooting scenarios with concrete fixes.
After an external system hammered a Spring Boot search endpoint causing database connection exhaustion, the author builds a distributed fixed-window rate limiter using Redis and Lua for atomicity, wraps it with an annotation-driven AOP aspect supporting user, IP, API key, and global dimensions, returns proper HTTP 429 with Retry-After, discusses fixed-window limitations versus token bucket and sliding window, and covers fail-open/fail-closed strategies for Redis outages plus monitoring metrics.
This article explains why a custom risk‑control component is needed for AI‑heavy services, outlines the requirement for real‑time adjustable limits, and walks through a Redis‑Lua based implementation of daily, hourly, and combined counters together with a Kotlin @Detect annotation for seamless integration.
This article details a production-ready distributed rate limiting system using Spring Boot AOP, Redis Sorted Sets, and atomic Lua scripts, covering sliding window and token bucket algorithms, multi-dimensional flash sale protection, and benchmark results showing 100% accuracy with minimal latency overhead.
The article walks through the evolution of a flash‑sale inventory‑deduction system, starting with simple database row‑locking SQL, exposing its scalability limits, and progressively adding transaction trimming, Redis pre‑deduction, Lua atomic scripts, async pipelines, idempotency, reconciliation and robust engineering practices to handle extreme concurrency.
This article provides a production‑grade, step‑by‑step engineering guide for designing a high‑concurrency seckill (flash‑sale) system that can sustain 100,000 QPS using Spring Boot, Redis with Lua scripts, asynchronous messaging, and comprehensive fault‑tolerance, monitoring, and scalability techniques.
This article presents a comprehensive, step‑by‑step analysis of building a flash‑sale (seckill) system that can survive instant traffic spikes, detailing seven essential design ideas such as static page delivery, token gating, Redis atomic decrement, asynchronous queuing, multi‑layer rate limiting, service isolation, idempotent processing, and end‑to‑end monitoring and recovery.
To survive a million concurrent flash‑sale clicks, the article breaks down a production‑grade, five‑layer architecture—CDN, load balancer, API gateway, Redis/Lua stock control, message‑queue order processing, and a state‑machine fallback—that filters traffic early, uses atomic operations, and decouples writes to keep database load to just a few QPS.
This guide explains how to build a dynamic IP blacklist for Nginx by comparing OS‑level iptables, Nginx deny rules, and application‑level checks, then detailing the chosen Nginx‑OpenResty, Lua, and Redis architecture, configuration snippets, and Lua script logic for automated blocking and rate limiting.
The article explains that although Spring Cloud Gateway offers token‑bucket rate limiting via Redis, adding a coarse‑grained Nginx limit protects the gateway from traffic spikes, reduces JVM pressure, and ensures continuous flow control even during restarts or GC pauses.
This article provides an in‑depth guide to Redis’s advanced capabilities, covering how to use pipeline for batch commands, transactions for ordered execution, Lua scripts for atomic logic, distributed locks with proper token handling, reliable messaging with streams, and specialized data structures such as BitMap, HyperLogLog, Bloom Filter and GEO for efficient large‑scale scenarios.
The article explains why a simple TCP proxy is insufficient for Kafka, and presents a production‑ready reverse‑proxy architecture built on Nginx stream and Lua that adds metadata rewriting, multi‑tenant quota, TLS termination, dynamic routing, observability, and graceful degradation to achieve scalable, auditable message ingestion.
The article details how the team built a high‑performance, reliable cloud‑native gateway for millions of AI sandbox VNC sessions, addressing challenges of dynamic pod IPs, multi‑stage Web VNC traffic, session consistency, and security by using OpenResty, Lua scripts, Redis‑backed routing, cookie‑based state storage, and extensive Nginx tuning.
The article introduces five recent open‑source projects—Usagi (a Rust+Lua 2D game engine), Oikos (a self‑hosted family planner), Breathe CLI (a terminal breathing trainer), Mini Macau (a Three.js 3D Macau transport visualizer), and 9Drive (a unified Google Drive gateway)—each with brief features, deployment notes, and GitHub links.
The article explains why placing rate limiting at the Spring Cloud Gateway layer, using Redis and Lua scripts, provides a high‑performance, distributed defense against traffic spikes, and walks through three algorithms, configuration parameters, code examples, and custom error handling for robust backend services.
The article examines the delayed double‑delete cache invalidation technique, reveals its hidden risk of cache‑penetration‑induced database load, compares Facebook's lease‑based solution and Uber's version‑number approach, and advises when the method is appropriate for high‑traffic systems.
This article examines the evolution of Redis distributed lock implementations—from the basic SETNX command to atomic SET with Lua scripts and the feature‑rich Redisson framework—detailing core requirements, common pitfalls, Go code samples, and production‑grade recommendations.
The article details how Verge, an AI‑assisted edge gateway built on the open‑source driver‑box framework, transforms a pure engine into a full‑featured, lightweight IoT platform by decoupling cloud and edge, offering rapid device integration, visual model editing, Lua scripting, and flexible deployment for smart building, industrial automation, and hobbyist labs.
This article explains why rate limiting is essential for both physical venues and online services, outlines common throttling strategies such as circuit breaking, service degradation, delay processing, and privilege handling, compares caching, degradation, and limiting, and details popular algorithms and concrete code examples for implementing rate limiting in Java and Nginx/Lua environments.
The article analyzes three Redis inventory‑deduction locking strategies—exclusive lock, segmented lock, and lock‑free/key‑quantization—detailing their key structures, suitable scenarios, advantages, drawbacks, and also covers Lua‑script atomic decrement, async queue buffering, and local pre‑deduction techniques.
The article analyzes why flash‑sale systems often crash under extreme traffic and presents a step‑by‑step solution using Spring Boot, Redis, and Lua that prevents overselling, pre‑warms stock, applies token‑bucket rate limiting, executes atomic stock deductions, and decouples order creation asynchronously while adding monitoring and safety measures.
The article compares four user‑level rate‑limiting approaches—Sentinel hotspot parameters, Sentinel ordinary flow control with cluster mode, Redis ZSet + Lua scripts, and Guava RateLimiter—explaining why Sentinel is unsuitable for long‑window low‑frequency limits and why Redis + Lua is the optimal solution for high‑traffic e‑commerce scenarios.
This guide explains how to use Nginx and OpenResty Lua scripts to implement rate limiting and circuit‑breaking for high‑concurrency services, detecting error rates and response latency, automatically opening and closing a 30‑second break window, and returning custom JSON responses when downstream services fail.
This article explains the fundamental differences between Nginx and OpenResty, compares their features, performance, and programming models, and provides practical guidance on selecting the right tool for static serving, reverse‑proxying, or complex business‑logic workloads.
The article examines Cloudflare’s December 2025 outage caused by a nil‑pointer bug hidden in Lua code, compares how Go and Rust would handle the same scenario, and extracts key operational lessons about global configuration, dynamic language risks, and the safety benefits of strong type systems.
This guide explains three practical ways to achieve dynamic IP blocking in Nginx—using Fail2ban, Lua with Redis, and Nginx's built‑in limit modules—detailing configuration steps, code examples, advantages, drawbacks, and best‑practice recommendations for various deployment scenarios.
This article explores four powerful Redis batch query methods—MGET, HMGET, pipeline, and Lua scripting—detailing their advantages, usage examples in Spring Boot, and practical considerations such as network latency reduction, client simplification, transaction performance, and atomic execution to enhance system efficiency under high-concurrency workloads.
This guide walks through constructing a high‑performance, cost‑effective enterprise‑level Web Application Firewall using OpenResty, covering why OpenResty is ideal, core architecture, modules for request lifecycle management, IP control, rate limiting, SQL injection and XSS detection, intelligent CC protection, monitoring, performance tuning, deployment tips, real‑world case study, and future enhancements.
This article explains how to evaluate system performance bottlenecks, choose between hard and soft rate‑limiting, and implement a non‑intrusive, high‑concurrency traffic‑control solution using OpenResty, Lua scripts, and Redis, covering architecture design, queue management, rate limiting, resource release, and performance testing.
This article explains load balancing concepts, why to use it, HAProxy's features and limitations, Lua extensions, step‑by‑step installation on CentOS, service setup, detailed configuration sections, logging options, and how to organize large HAProxy setups with sub‑configuration files.
This tutorial explains how to integrate Lua scripts into Java applications and how to call Java code from Lua, covering the LuaJ and LuaJava libraries, Maven dependencies, code examples for executing Lua, passing functions, dynamic extensions, and automatic script upgrades.
This article walks through designing and implementing an enterprise‑grade API gateway with Nginx and OpenResty, covering architecture, dynamic routing, load balancing, rate limiting, circuit breaking, authentication, request transformation, caching strategies, observability, high‑availability deployment, and real‑world performance results.
This guide explains how to create a dynamic IP blacklist that blocks malicious crawlers or users by rejecting requests from listed IPs, supports configurable expiration, and is implemented using Nginx (OpenResty), Lua scripts, and Redis for shared, lightweight, and scalable protection.
This article explains how to build a dynamic IP blacklist using Nginx, Lua scripts, and Redis, covering the problem definition, environment setup, design choices, Nginx configuration, Lua script implementation, testing, and extensions such as use‑case scenarios and advanced features.
This guide explains how to create a dynamic IP blacklist that blocks malicious crawlers and users by configuring Nginx with Lua scripts and a Redis store, covering requirements, environment setup, design options, configuration files, Lua code, summary of benefits, use cases, and advanced extensions.
This article analyzes current system performance bottlenecks, compares hard‑rate‑limiting and flexible queuing strategies, and presents a non‑intrusive traffic‑control solution built with OpenResty+Lua and Redis that offers zero‑code changes, high performance, scalability, and real‑time visual feedback for high‑concurrency scenarios.
This article explains how OpenResty, built on Nginx and Lua, can be used in production to implement interface authentication, traffic control, and request logging, detailing practical implementation steps, configuration examples, and code snippets that help improve service reliability and operational efficiency.
This article introduces Easy-Cache, a Spring-AOP based caching framework that provides annotation-driven, multi-level Redis and local cache with dynamic upgrade/downgrade, elastic expiration, and Lua-script-ensured data consistency, eliminating repetitive cache code and handling failures, cache penetration, breakdown, and eventual consistency challenges.
This article presents a hands‑on guide to using OpenResty—Lua‑enhanced Nginx—for implementing static and dynamic blacklists, fine‑grained rate limiting, A/B testing via upstream selection, and real‑time service quality monitoring, all with production‑ready code examples.
This article introduces Easy-Cache, a Spring‑AOP based caching framework that eliminates repetitive cache code by offering annotation‑driven operations, multi‑level Redis and local caches, dynamic upgrade/downgrade, elastic expiration, and Lua‑script‑backed consistency mechanisms for high‑availability distributed systems.
This article explains the role of an access gateway, outlines its architecture and core functions, and demonstrates how to design and implement a dynamic, plugin‑based gateway using OpenResty (Nginx + Lua), including routing, shared data, and dynamic upstream management.
This article walks through the design, pitfalls, and step‑by‑step implementation of a token‑bucket rate‑limiting middleware for the Webman PHP framework, highlighting the need for atomic Redis operations and showing how a Lua script resolves concurrency issues in distributed environments.
This article explains how to implement precise sliding‑window rate limiting using a Redis Lua script and a Spring‑based Java component, compares it with fixed‑window and token‑bucket approaches, and provides advanced techniques, production tips, and performance optimizations.
This article explains why rate limiting is critical for micro‑service architectures, compares implementations across Dubbo, Spring Cloud, Guava, Sentinel and Redis+Lua, and shows how to build reusable AOP annotations and a Spring‑Boot starter to apply throttling consistently across services.
This article explains how to implement a precise sliding‑window rate‑limiting algorithm using Redis Sorted Sets, detailing the problem scenario, the algorithm steps, Lua script implementation, Java integration, and practical extensions for high‑performance backend services.
This article explains how to implement distributed locks using Redis, covering basic SETNX/EXPIRE techniques, common pitfalls, atomic Lua scripts, the RedLock algorithm, and practical Redisson usage, while providing Java code examples and best‑practice recommendations.
This article explains the concept of rate limiting, compares five common algorithms—including fixed‑window, sliding‑log, sliding‑window counter, token bucket and leaky bucket—covers distributed designs using Redis and Lua scripts, and provides complete FastAPI implementation and pytest tests for both fixed‑window and sliding‑log strategies.
Lua, a lightweight scripting language born in Brazil in 1993, overcame early obscurity to become a globally adopted tool for game development, embedded systems, and diverse applications, illustrating how a small team can solve a universal need and achieve worldwide success.
This guide explains step‑by‑step how to set up a Web Application Firewall by installing LuaJIT, ngx_devel_kit, lua‑nginx‑module, compiling Nginx with Lua support, fixing common errors, and optionally using OpenResty, followed by configuring and testing the ngx_lua_waf module.
This guide explains how to use Nginx, Lua (via OpenResty), and Redis to automatically block any IP that exceeds 60 requests per minute, storing the blacklist in Redis with a default one‑day ban and providing performance optimizations and testing steps.
This article explains how to integrate Lua scripts into a Spring Boot application to leverage Redis's atomic execution, reduce network overhead, and improve performance, covering Lua fundamentals, reasons to choose Lua, practical use‑cases, step‑by‑step implementation, error handling, security considerations, and best practices.
This article explains how to set up a dynamic IP blacklist using Nginx, Lua scripts, and Redis, covering environment preparation, design options, configuration of nginx.conf, Lua script implementation, and advanced features such as rate limiting, white‑listing, and automated detection to protect servers from malicious traffic.
This article explains how to design and implement a business-specific rate‑limiting component in Kotlin using Redis Lua scripts and Spring AOP annotations, covering the motivation, rule definitions, counting strategies, Lua script details, annotation creation, and a practical usage example.
This article details how Ctrip's Soft Load Balancer (SLB) transitioned from a simple Nginx reverse‑proxy to a multi‑datacenter, dynamic routing gateway using OpenResty, Lua scripts, and a three‑layer architecture that eliminates reloads and supports high‑frequency configuration updates.
This article introduces a comprehensive Spring Boot 3 practical case collection and walks through building a reentrant, auto‑renewing distributed lock using Redis and Lua scripts, providing full code snippets and configuration guidance for robust backend concurrency control.
This article walks through the problem of locking out users after multiple failed login attempts, explains why IP‑based locking with Redis and Lua scripts is effective, and provides a complete Spring Boot implementation—including front‑end HTML, custom annotations, AOP aspect, Redis configuration, and sample controller code—to enforce a configurable login‑attempt limit.
This article introduces the lightweight Lua scripting language, outlines its key features and typical use cases, and provides a complete example of using Redis together with Lua scripts (and a Java client) to enforce IP‑based login‑attempt limits for improved security.
This article explains how to integrate Lua scripts into Spring Boot applications with Redis, covering Lua fundamentals, advantages of Lua in Redis, practical use cases, step‑by‑step implementation in Spring Boot, performance optimizations, error handling, security considerations, and best practices for reliable backend development.
This tutorial explains how to combine Spring Boot and Redis using Lua scripts, covering Lua fundamentals, performance advantages, practical use cases, step‑by‑step implementation in Spring Boot, error handling, security considerations, and best‑practice recommendations for backend developers.
This article introduces Lua scripting in Redis, explains its fundamentals and advantages, and provides step‑by‑step instructions for integrating and executing Lua scripts within a Spring Boot application, including code examples, performance optimization, error handling, security considerations, and best practices.
This article demonstrates how to build a dynamic IP blacklist using Nginx, Lua scripts, and Redis, covering requirements, environment setup, design options, nginx.conf configuration, detailed Lua code, summary of advantages, and extensions such as use cases and advanced features.
This article examines why many large‑scale systems avoid the traditional delayed double‑delete cache‑invalidation strategy, explains its critical drawbacks, and presents alternative lease‑based and version‑based approaches with Lua scripts and Java wrappers for Redis to achieve stronger consistency.
This guide explains how to create a dynamic IP blacklist that blocks malicious crawlers or users by configuring Nginx with Lua scripts and a Redis store, covering requirements, environment setup, design choices, configuration files, Lua code, and advanced usage scenarios.
This article explains the challenges of thread synchronization in distributed systems, introduces the concept of distributed locks, compares common implementations such as Redis, Zookeeper, and databases, and provides robust Java and Lua solutions to ensure atomicity, avoid deadlocks, and support lock renewal.
This article explains how to prevent brute‑force password attempts by locking an IP after three failed logins using a Spring Boot backend, Redis for distributed counters, and a Lua script to ensure atomic increment and expiration, while also providing a simple HTML login page for the front end.
This article demonstrates how to implement a login attempt limiting mechanism using Spring Boot, Redis, and Lua scripts, explaining the problem of repeated password failures, the design of IP-based rate limiting, and providing complete front‑end and back‑end code examples with configuration details.
This guide walks through installing LuaJIT, ngx_devel_kit, and lua-nginx-module, compiling Nginx with Lua support, fixing common libluajit errors, optionally installing OpenResty, and configuring the ngx_lua_waf module to protect web applications.
This tutorial explains how to install LuaJIT, ngx_devel_kit, and lua‑nginx‑module, compile Nginx with Lua support, resolve common libluajit errors, optionally install OpenResty, and configure the ngx_lua_waf module to protect web applications.
This article explains how to build a dynamic IP blacklist that blocks malicious crawlers or users by using Nginx with a Lua access script and Redis for storage, covering requirements, environment setup, design choices, configuration steps, Lua code, and advanced extensions.
This article explains how to implement distributed locks in Redis using the SETNX command, atomic Lua scripts, the Redisson Java client, and the RedLock algorithm, providing code examples and discussing their advantages and limitations in distributed backend systems.
Fennel is a Lisp‑style programming language built on Lua that offers zero‑overhead compilation, full Lua compatibility, compile‑time macros, and easy embedding, making it ideal for creating games and art in environments like TIC‑80, while preserving the simplicity of s‑expressions.
This guide walks through installing LuaJIT, ngx_devel_kit, lua-nginx-module, compiling Nginx with Lua support, troubleshooting common errors, and adding a Lua-based Web Application Firewall (WAF) on an OpenResty platform.
This article compares three inventory deduction approaches—single‑field MySQL updates, sharded MySQL records, and Redis INCRBY with Lua scripting—analyzes their concurrency drawbacks, and provides a complete Java implementation using Redis Lua scripts, distributed locks, and callback‑based stock initialization.
This article compares Java backend development with game engine programming, explains why Unreal Engine (C++) and Unity (C#) dominate modern games, outlines official Unreal learning paths, and introduces hot‑update techniques using Blueprints, USharp and Lua for dynamic game updates.
This article explains how to produce Lua‑level flame graphs for OpenResty by leveraging SystemTap’s lj‑lua‑stacks tool, demonstrates the underlying data structures and call‑stack extraction, and explores a possible eBPF‑based rewrite for safer, kernel‑level tracing.
This guide introduces the lightweight Lua‑resty‑template engine for OpenResty, explains its typical use cases, shows how to install and configure it, and provides step‑by‑step examples of basic and advanced template rendering with code snippets and configuration files.
This article introduces Nginx’s extensive built‑in variables, shows how to access them in OpenResty with ngx.var, and provides step‑by‑step Lua examples ranging from a simple arithmetic endpoint to a basic IP‑based firewall and rate‑limiting configuration.
This article explains how to implement a Redis distributed lock, covering the basic SETNX approach, adding expiration, handling lock release errors with renewal and unique identifiers, achieving atomicity via Lua scripts, and discussing the inherent challenges of network delay, process pause, and clock drift in distributed systems.
This guide walks you through setting up a local virtual domain for OpenResty, creating and editing configuration files, adding Lua location blocks, using external Lua script files, managing the lua_code_cache setting, and troubleshooting errors with practical command examples.
This article explains how to implement distributed locks using Redis, starting with a simple SETNX approach, identifying its shortcomings, and then presenting solutions such as thread‑identifiers, Lua scripts for atomicity, handling TTL with watchdogs, the RedLock algorithm, and practical usage via the Redisson Java client.
This article explains how to embed Lua scripts in Java applications with LuaJ, how to call Java code from Lua using LuaJava, and demonstrates dynamic extension, script auto‑upgrade, and bidirectional interaction through comprehensive code examples and detailed explanations.
This article explains why a custom business risk‑control module is needed, outlines the required features, and provides a complete Kotlin‑based implementation that uses Redis + Lua scripts for daily and hourly counting, as well as a Spring annotation for seamless integration.
During flash‑sale events like JD or Taobao, a tiny fraction of products generate the majority of traffic, causing server overload; this guide explains how to identify and collect hotspot product data in real time using an OpenResty‑Lua front‑end, Kafka for messaging, and Elasticsearch for storage and analysis.
This article explains how to design a high‑QPS hotspot data caching and retrieval system for e‑commerce homepages using OpenResty, Lua, Redis, and a message queue, detailing publishing, reading processes, workflow diagrams, and a complete Lua script that can sustain tens of thousands to millions of concurrent requests.
This article explains how Redisson leverages Redis to implement distributed locks, detailing the underlying Lua scripts, lock acquisition and release processes, the watch‑dog mechanism for automatic lease renewal, and provides Java code examples for integrating and testing the lock functionality.
Lua is a lightweight, high-performance scripting language supporting multiple paradigms, widely used in game development, embedded systems, and web servers; this guide explains its core characteristics, typical applications, and provides step-by-step instructions for downloading, compiling, and configuring Lua on a Linux system.
The article describes a high‑throughput, fault‑tolerant data‑collection pipeline built with OpenResty, Lua, and Kafka that writes incoming records to disk using a cross‑worker mutex and cached file handles, rotates files via Nginx reload, and achieves over 13× performance versus typical online methods.
This article explains how to integrate Lua scripts with Redis in a Spring Boot application, covering Lua basics, performance benefits, common use cases, step‑by‑step configuration, Java code examples, error handling, security considerations, and best practices for reliable backend development.
This article explains how to integrate Lua scripts into Spring Boot applications for Redis, covering Lua fundamentals, performance benefits, common use cases, step‑by‑step implementation with Spring Data Redis, error handling, security considerations, and best‑practice recommendations.
This article explains how to integrate Lua scripts into Spring Boot applications using Redis, covering Lua basics, advantages of Lua in Redis, practical use cases, step‑by‑step implementation with code examples, performance optimization, error handling, security considerations, and best practices for reliable backend development.
The article shows how OpenResty’s Lua‑based extensions can implement lightweight, version‑controlled API authentication, dynamic traffic‑shaping via shared‑memory peer status, and selective request tracing with batch‑sent logs to Elasticsearch, enabling secure, highly available services and rich observability without sacrificing Nginx performance in production.
This article explains why a custom business risk‑control (rate‑limiting) component is needed for AI‑intensive services, compares open‑source solutions, and provides a complete backend implementation using Redis+Lua scripts, Kotlin code, Spring AOP annotations, and real‑time adjustable rules.
This article explains how to integrate Lua scripts into Spring Boot applications using Redis, covering Lua fundamentals, advantages of Lua in Redis, practical use cases, step‑by‑step implementation, performance optimization techniques, error handling, security considerations, and best practices for reliable backend development.
This article explains APISIX’s multi‑process architecture and request lifecycle, then explores various ways to develop external plugins—including SideCar‑based plugins, WASM modules, and LuaJIT FFI—detailing their implementation steps, advantages, and limitations to help developers choose the optimal approach for extending the cloud‑native gateway.
This article explains how to integrate Lua scripts into Spring Boot applications using Redis, covering Lua fundamentals, performance benefits, practical use cases, step‑by‑step implementation, error handling, security considerations, and best practices for optimizing backend services.