OpenResty and API Gateway Learning Guide
This guide compiles resources and key concepts on OpenResty, Lua‑based Nginx development, asynchronous programming models, microservice API gateways, and related plugins, providing a structured roadmap for backend engineers to deepen their understanding and practical skills.
Discussion topics include machines, languages, and architectures such as reactor, coroutine, and cache.
Learning Guide #1
Reactor – http://blog.csdn.net/u013074465/article/details/46276967
Coroutine – http://blog.csdn.net/wyx819/article/details/45420017
Tornado IOLoop code reading notes – http://t.cn/R5XxpMM
Synchronous Programming
Multithreading, user‑mode/kernel‑mode switching
Blocking leads to thread switching
Asynchronous Programming
Event‑driven model
Callbacks
Coroutines
OpenResty
Nginx
lua‑nginx‑module
lua resty libraries – https://github.com/iresty/nginx-lua-module-zh-wiki#description
ngx_lua module principles
Each worker creates a Lua VM; all coroutines in the worker share the VM.
Nginx I/O primitives are wrapped and injected into the Lua VM, allowing direct Lua access.
Each external request is handled by a Lua coroutine, providing data isolation between coroutines.
When Lua code calls asynchronous I/O, the current coroutine is suspended without blocking the worker.
Upon I/O completion, the coroutine context is restored and execution resumes.
Learning Guide #2
OpenResty series course – http://www.stuq.org/course/1015
Agentzh Nginx tutorial – https://openresty.org/download/agentzh-nginx-tutorials-zhcn.html
OpenResty best practices – https://moonbingbing.gitbooks.io/openresty-best-practices/content/
nginx‑lua‑module‑zh‑wiki – https://github.com/iresty/nginx-lua-module-zh-wiki
API Gateway
Microservices
Entry point
Authorization, monitoring, load balancing, caching, request sharding, static response handling
Learning Guide #3
Microservices – http://blog.csdn.net/wurenhai/article/details/37659335/
API Gateway – http://dockone.io/article/482
Kong
Based on OpenResty
Provides a rich plugin ecosystem
Highly customizable plugins
Learning Guide #4
Kong source analysis – http://cyukang.com/2017/07/02/kong-intro.html
Deep dive into orange – https://github.com/linger1216/understanding-orange
Custom Requirements
eebo auth – independent auth module, flexible API auth configuration, Python services need not handle authentication details.
eebo limiting – built‑in rate limiting with company_id/user_id dimensions.
eebo balancer – private service provision with powerful distributed distribution.
Built‑in Plugins
CORS – handles cross‑origin requests.
IP Restriction – IP whitelist/blacklist.
Correlation ID – generates a unique request ID for each request, aiding tracing and logging.
Syslog – forwards logs to Syslog.
Source: https://zhu327.github.io/2017/11/27/openresty%E4%B8%8Eapi-gateway/
Copyright notice: Content is sourced from the web, copyright belongs to the original authors. We will credit the author and source unless verification is impossible; please inform us of any infringement.
Architecture Digest
Focusing on Java backend development, covering application architecture from top-tier internet companies (high availability, high performance, high stability), big data, machine learning, Java architecture, and other popular fields.
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.