TL;DR coco is a simple stackless, single-threaded, and header-only C++20 coroutine library that leverages native C++20 coroutines for async/await programming with Go-like channels and waitgroups. https://github.com/kingluo/coco Background Don’t communicate through shared memory, share memory through communication. I have always been impressed by Golang’s CSP programming, which is very…
TL;DR coco is a simple stackless, single-threaded, and header-only C++11 coroutine library. https://github.com/kingluo/coco Background Don’t communicate through shared memory, share memory through communication. I have always been impressed by Golang’s CSP programming, which is very expressive and couples different business logic together through channels.
In Envoy, both lua-resty-ffi (envoy porting) and the built-in golang filter allow you to use golang to develop asynchronous business logic through goroutine, but which one performs better? Call flow When the headers of an incoming request get parsed by envoy, an HTTP filter’s decodeHeaders() is called.
TL;DR In openresty, using ngx.location.capture(), we can achieve high-performance asynchronous processing of upstream responses. Motivation As we all know, due to the design limit, nginx header/body filters are synchronous and you should not perform blocking operations such as blocking system calls, decrypting, decompressing, or forwarding responses to other servers for further processing.
TL;DR I’ve created a new HTTP/3 testing framework based on bash and curl: https://github.com/kingluo/burl Chinese blog version: https://zhuanlan.zhihu.com/p/675741855 Background A few months ago, when I ported the QUIC patches from the nginx mainline to APISIX and tried to test it, I found that test::nginx didn’t work very well.
Background Both nginx and envoy are high-performance proxy server software. They are written in C/C++ so they run fast. But the C/C++ ecosystem is notoriously weak. Can we do hybrid programming with Go, Java, Python, Rust or NodeJS? so we can use Those rich ecosystems of popular mainstream programming languages?
TL;DR How can I log the Lua execution time of each request (excluding time spent on asynchronous IO) in ngx.ctx in a non-intrusive, zero-cost way? The Lua execution time is the sum of the following metrics: lua_resume phases REWRITE ACCESS CONTENT BALANCER lua_pcall filters header_filter body_filter https://github.
Background HTTP/3 is the third major version of the Hypertext Transfer Protocol used to exchange information on the World Wide Web, complementing the widely-deployed HTTP/1.1 and HTTP/2. Both HTTP/1.1 and HTTP/2 use TCP as their transport. HTTP/3 uses QUIC, a transport layer network protocol which uses user space congestion control over the User Datagram Protocol (UDP).
Background Kerberos is a computer network security protocol that authenticates service requests between two or more trusted hosts across an untrusted network, like the internet. It uses secret-key cryptography and a trusted third party for authenticating client-server applications and verifying users’ identities.
As known, nginx modules are static linking. Of course, you could also use dynamic modules, but they are limited to use dynamic symbols from nginx executable. What if I need to use static variables and functions from nginx executable in my code?
Asynchronous programming or async for short, is a concurrent programming model supported by an increasing number of programming languages. It lets you run a large number of concurrent tasks on a small number of OS threads, while preserving much of the look and feel of ordinary synchronous programming, through the async/await syntax.
lua-resty-ffi provides an efficient and generic API to do hybrid programming in openresty with mainstream languages (Go, Python, Java, Rust, Nodejs, etc.). https://github.com/kingluo/lua-resty-ffi I already implement code hot-reload for Python and Nodejs in lua-resty-ffi. The Java class reloading is the last piece of the puzzle.
As known, Node.js is a popular javascript runtime based on V8 and libuv, with many third-party packages managed by npm. How to enable nodejs in openresty, so that we could reuse its rich ecosystem? Check https://github.com/kingluo/lua-resty-ffi/tree/main/examples/nodejs for source code. lua-resty-ffi https://github.com/kingluo/lua-resty-ffi
Back in 2019, when I work as individual postgresql/nginx consultant. Many clients ask me if they could do hybrid programming in nginx. They said, nginx/openresty is powerful and high performance, but the most significant drawback is it lacks of ecosystem of mainstream programming languages, especially when they have to interact with popular frameworks, e.
Rust is a complex programming language, with a lot of concepts. When you find the concept hard to understand, perhaps checking the assembly code would be helpful. It’s my favourite way to learn Rust. Move In Rust, we have to use move in most time.
flatBuffers is an efficient cross platform serialization library for C++, C#, C, Go, Java, Kotlin, JavaScript, Lobster, Lua, TypeScript, PHP, Python, Rust and Swift. It was originally created at Google for game development and other performance-critical applications. In lua/luajit, is flatbuffers really faster than json?
I work on a remote terminal most of the time. This article collects some tips from my experience. bash multiple line editing Sometimes a complex command consists of multiple lines and you need to edit them before executing it. The lines may be in any format, e.
Vim, the god of editor, is popular in developers and hackers. I use vim over two decade (when I am in the college, I already use vim to write VHDL code to programming the chip). A lot of people install many plugins into vim, and even turn vim into IDE, which is cumbersome and unnecessary in my eye.
What’s blocking? Nginx has one master process and multiple worker processes, and each worker process is single threading. It’s well known that NGINX uses an asynchronous, event‑driven approach to handling connections. This means that instead of creating another dedicated process or thread for each request (like servers with a traditional architecture), it handles multiple connections and…
Use systemtap to analyze the memory leak of lua code The memory used by lua code is managed by the GC, not calling malloc/free/mmap directly. The luajit GC uses mark-and-sweep algorithm. In simple words, it links all allocated gc objects in a global list.
Without questioin, gdb is a brilliant weapon to debug our program. However, the reality is complex. We need black magics to handle these cases. Magic1: optimized out? Your program is normally compiled in optimized mode (e.g. -O2), sometimes even without debug info!
Why string interning? String Interning is a common optimization in most of programming languages. As the wiki said: In computer science, string interning is a method of storing only one copy of each distinct string value, which must be immutable.[1] Interning strings makes some string processing tasks more time- or space-efficient at the cost of requiring more time when the string is created or…