The ultimate solution to buried logs–Golang + Gin + Sarama VS Java + SpringWebFlux + ReactorKafka I have written several articles before about OpenResty + lua-kafka-client writing buried data to Kafka, as follows: Lua writes Nginx request data to Kafka – buried log solution Python scheduled task executes shell script to cut Nginx logs – […]
Tag: reactor
Reactor pattern
Article directory 1. Single-threaded Reactor reactor mode 2. Multi-threaded Reactor reactor mode In Java’s OIO programming, the original and most primitive network server program uses a while loop to constantly monitor the port for new connections, and if so, calls a processing function to handle it. The biggest problem with this method is that if […]
7. epoll edge trigger and reactor
epoll edge trigger 1. epoll event model: ? epoll monitors file descriptors and can also monitor inter-process communication events. #include <stdio.h> #include <stdlib.h> #include <sys/epoll.h> #include <errno.h> #include <unistd.h> #defineMAXLINE 10 int main(int argc, char *argv[]) {<!– –> int efd, i; int pfd[2]; pid_t pid; char buf[MAXLINE], ch = ‘a’; pipe(pfd);//Create a pipe pid = […]
Echo server based on multi-threaded Reactor mode EchoServer
record A thread is dedicated to accepting accept and obtaining the client’s fd. After obtaining fd, find a thread with the smallest number of connected clients from the remaining execution threads. Then add the client’s fd to this thread and monitor this fd through EPOLL Threads communicate through eventfd, passing the client’s fd to the […]
Java Reactive Programming: An in-depth exploration of Reactor and RxJava
In today’s high-concurrency, high-response, and high-throughput software systems, the Reactive programming model has gradually become a very important development model. It allows developers to handle asynchronous data streams in a more responsive manner, providing a smoother and scalable user experience. In the Java world, there are two very popular libraries that support Reactive programming: Reactor […]
Reactive programming Reactor
Reactive programming Reactor Background Introduction to synchronization, asynchronous, blocking, and non-blocking. Introduction to network programming models. Traditional imperative programming has some limitations when facing current needs. Current needs: Applications need to be highly available and provide low latency even when application load is high. Performance overhead caused by synchronization A request comes in and waits […]
Reactor mode network library encapsulation based on IO reuse (epoll)
Article summary: 1. Understand the main goals and ideas of network library encapsulation. 2. Understand the Reactor pattern. 3. Code implementation. 1. Network library encapsulation 1.1 What is the purpose of the network library? The encapsulated network library acts between the application layer and transport layer that process services. Programmers can know where the information […]
Server IO multiplexing reactor mode
#include <iostream> #include <vector> #include <queue> #include <thread> #include <mutex> #include <condition_variable> #include <unistd.h> #include <cstring> #include <sys/socket.h> #include <netinet/in.h> #include <fcntl.h> #include <functional> #include <future> #include <algorithm> const int MAX_CLIENTS = 10; const int BUFFER_SIZE = 1024; const int MAX_THREADS = 4; structEventData {<!– –> int clientSocket; }; class ThreadPool {<!– –> public: ThreadPool(size_t […]
ProjectReactor mode server
Table of Contents Reactor complete code connection Prerequisite knowledge: 1. What are the problems with ordinary epoll reading and writing? 2.What is the callback function in Connection? 3. Server initialization (Connection is just a structure used) 4. Wait for the ready event: When the event is ready, call the corresponding callback method for different objects […]
Encapsulate reactor to achieve millions of concurrency
First, reactor uses an epoll to encapsulate I/O multiplexing. For each received connfd, if the global receive buffer and send buffer are used, dirty reading will occur. Therefore, a structure must be established, an object must be created for each connfd, and the corresponding object must be created inside the structure. socket buffer struct sock_item […]