This article explores how Netty’s IntObjectHashMap improves high‑concurrency ticket‑pricing scenarios by using primitive int keys, open‑addressing linear probing, and careful capacity adjustments, revealing the source‑code evolution, hashIndex optimizations, load‑factor tuning, and deletion compaction that together deliver significant memory and CPU savings.
This article introduces CIM, a developer‑oriented distributed instant messaging platform, outlines its current features and roadmap, explains its SpringBoot‑Netty‑Redis‑Zookeeper architecture, and provides detailed installation, configuration, and usage instructions with code examples.
This article introduces Netty, explains Java's BIO/NIO/AIO models, compares reactor threading architectures, details Netty's internal thread and handler pipeline design, and provides a complete example of building a high‑performance HTTP server with Netty.
This article presents a complete tutorial on building a TCP‑based instant‑messaging system using Netty for the server, SpringBoot for the web admin console, JavaFX for the desktop client, Shiro for authentication, and MySQL for user data, covering architecture, protocol design, and full source code examples.
This article reveals a subtle memory‑leak bug in Netty 4.1.56.Final’s Recycler object pool, explains its intricate lock‑free design for object allocation and recycling across threads, and walks through the discovery, analysis, and eventual fix of the issue.
This article explains the time wheel timer algorithm, its basic design, how tasks are added and expire, the need for dynamic and hierarchical wheels, and illustrates these concepts with examples from Kafka and Netty, using animated diagrams for clarity.
This article provides a comprehensive guide to building a custom RPC framework, covering core concepts, architecture diagrams, registration with Zookeeper, Netty communication, custom message protocols, serialization, load balancing, handling TCP packet issues, and practical deployment steps with starter modules.
This article walks through the limitations of traditional Java IO, explains how NIO and its selector mechanism solve thread‑resource and efficiency problems, and demonstrates why Netty’s higher‑level abstraction makes network programming far simpler and more performant, complete with runnable code examples.
This guide explains the fundamentals of Netty, shows how to combine it with Spring MVC using DispatcherServlet, and provides complete Java code examples for a Netty server, channel pipeline, request handler, server startup, and a sample controller, along with practical configuration tips.
This article explains how to combine Netty and Spring MVC by creating a Netty server, configuring the channel pipeline, implementing a request handler that forwards to DispatcherServlet, initializing the servlet, and providing a sample controller with troubleshooting tips for character encoding and configuration files.
This article explains the complete flow of how Netty's Sub‑Reactor processes OP_READ events, from selector polling to channel pipelines, and details the adaptive mechanisms of AdaptiveRecvByteBufAllocator and PooledByteBufAllocator that dynamically resize DirectByteBuffers for optimal network data reception.
This article details the design and implementation of an online customer service instant messaging system, covering requirements analysis, client‑server network model, HTTP and WebSocket protocols, distributed architecture choices such as routing rules, Redis shared memory, server‑master sync, and message‑queue broadcasting, and explains why Netty was selected as the development framework.
This article dissects Netty’s core connection‑acceptance mechanism, explains how the OP_ACCEPT event is processed, reveals a subtle bug that limits read loops to a single connection, and shows the fix introduced in version 4.1.69.final, offering developers a complete understanding of Netty’s reactor architecture.
This article presents a detailed overview of a custom Java RPC framework, covering its core concepts, architecture, communication flow, message protocol, load balancing, serialization, handling of TCP packet fragmentation, and practical implementation using Spring Boot, Netty, and Zookeeper, along with deployment instructions.
This article walks through building a simple Netty HTTP server, explaining how thread groups, channel options, handlers, and the bind operation work together to start a server, and highlights key implementation details such as selector creation and performance‑focused choices.
This article explains the fundamentals of Remote Procedure Call (RPC), detailing the definition, basic call flow, service interface design, server registration with Zookeeper, Netty-based network communication, dynamic proxy generation on the client side, and provides complete Java code examples for a working RPC framework.
This article surveys various delayed queue implementations—including Kafka, RocketMQ, Redis (Redisson), and Netty’s HashedWheelTimer—examining their design principles, advantages, drawbacks, and integration strategies, and proposes a unified micro‑service architecture leveraging Kafka topics, Redis ZSETs, and thread‑pool optimizations for reliable message scheduling.
This article explains the fundamentals of Remote Procedure Call (RPC), walks through the complete request‑response flow, and provides a step‑by‑step Java implementation using Spring, custom XML namespaces, Netty for network communication, and Zookeeper for service registration and discovery.
Explore the comprehensive step-by-step process of Netty server startup, covering channel creation, initialization, reactor registration, and binding, while demystifying the asynchronous flow and internal mechanisms that power high-performance network applications.
This article examines why Netty has become the preferred high‑performance server framework over Tomcat, covering Java I/O models, zero‑copy techniques, off‑heap memory usage, and Netty’s custom object‑pooling, and explains how these features enable handling thousands of concurrent connections efficiently.
This article explains how Netty constructs its core reactor thread pool using NioEventLoopGroup, detailing the creation of boss and worker groups, the underlying selector optimization, task queue setup, and the round‑robin binding strategy that distributes channels across multiple event loops for high‑performance I/O handling.
This article explains how the ZhiZhi RPC framework SCF handles connection lifecycle, including establishment timing, connection pooling versus multiplexing, keep‑alive mechanisms, automatic recovery, and graceful shutdown, providing practical guidance for designing robust RPC protocols.
This article explains the concepts, architecture, communication flow, and implementation details of a custom RPC framework built with Spring Boot, Netty, and Zookeeper, covering service registration, load balancing, custom message protocols, serialization, TCP handling, and deployment steps.
This article explains the fundamentals of Remote Procedure Call (RPC), detailing the end‑to‑end workflow—from interface definition and dynamic proxy generation on the client, through service registration in ZooKeeper, to server‑side handling with Spring and Netty—accompanied by complete Java code snippets and configuration examples.
This tutorial explains why Netty is preferred over raw NIO, introduces its core components and architecture, and walks through a complete Java example of a simple Netty chat server, including handling of connections, message broadcasting, pipeline configuration, and TCP sticky‑packet issues.
This article describes how to design and build a high‑throughput, extensible gateway using Spring WebFlux, Netty, and Nacos, covering technical selection, architecture, core modules, plugin chain, data synchronization, WebSocket cache, testing, and performance results.
This article provides a comprehensive overview of Java NIO network programming, explaining BIO, NIO, and AIO models, the core components Channel, Buffer, and Selector, and how Netty leverages the Reactor pattern with multi‑threaded boss and worker groups for high‑performance asynchronous I/O.
This article provides a comprehensive overview of Java network programming fundamentals, including socket basics, IO models (BIO, NIO, AIO), NIO core components such as Channel, Buffer, and Selector, and detailed example code for building NIO client‑server applications.
This article examines the importance of resource isolation in distributed systems, covering thread, process, cluster, data‑read/write, static, and crawler isolation, and illustrates practical implementations with Netty, Dubbo, Tomcat, and Hystrix, including code snippets and configuration tips.
This article analyzes the challenges of multi‑user WebSocket communication in a clustered environment, compares Netty and Spring WebSocket implementations, and presents two practical solutions—session broadcast and a consistent‑hashing based routing scheme—complete with code samples, gateway configuration, and load‑balancing considerations.
The author, a second‑year master's student in Java backend development, summarizes interview questions and experiences from JD, Meituan, Alibaba, Toutiao and Kuaishou, covering Java concurrency, JVM locking, Netty, Redis, MySQL/HBase, distributed systems, and several algorithm problems.
This article explains the fundamentals of I/O, details how sockets are created, bound, listened to, and accepted, describes the client-side connect process, and clarifies why read, write, accept, and connect operations can block, laying the groundwork for deeper Netty studies.
This article explains the motivation behind Netty's FastThreadLocal, compares it with JDK ThreadLocal, details its internal implementation—including InternalThreadLocalMap, FastThreadLocalThread, and key methods like get()—and discusses its performance benefits, resource recycling mechanisms, and practical usage in Netty's ByteBuf allocation.
This article walks through creating a real‑time video bullet‑chat system using Netty as the backend server and WebSocket for bidirectional communication, covering technology selection, architecture design, data flow, and detailed Java and HTML/JavaScript code to implement the interactive feature.
This article explains why Netty introduced FastThreadLocal, how it avoids the hash‑collision overhead of JDK ThreadLocal by using an indexed array, details the core classes and methods involved, and describes the three cleanup mechanisms and its practical use in Netty's ByteBuf allocation.
The article explains the concept of delayed tasks versus scheduled tasks and provides five Java‑based solutions—Quartz polling, JDK DelayQueue, Netty HashedWheelTimer, Redis (zset and keyspace notifications), and RabbitMQ delayed queues—detailing their implementations, advantages, and drawbacks.
This article presents the evolution, architecture, and engineering practices of Ctrip's API gateway, covering its transition to full asynchronous processing with Netty and RxJava, stream‑based forwarding, single‑threaded event‑loop design, performance optimizations, multi‑protocol support, routing, and modular governance for large‑scale microservice environments.
The article explains why resource isolation is essential for distributed architectures, describes common isolation methods such as thread, process, cluster, data, static and crawler isolation, and provides concrete examples and code snippets for Netty, Dubbo, Tomcat, and Hystrix to illustrate practical implementations.
This article explains how Netty abstracts Java NIO's event registration by using SelectionKey interestOps, detailing the registration of OP_ACCEPT and OP_READ events, the underlying doRegister and doBeginRead implementations, and the flow of events through the Netty pipeline with illustrative code snippets.
In a high‑throughput mobile push service built on Netty, an off‑heap memory leak was traced to unchecked ChannelOutboundBuffer growth when half‑closed connections remained active but unwritable; fixing it by disabling autoRead on unwritable channels, configuring write‑buffer watermarks, and adding explicit isWritable() checks eliminated the crash and stabilized the system.
This article examines Dubbo’s connection‑control feature, demonstrates how long‑living TCP connections are created, runs benchmark tests with one and two connections, discovers that varying IO thread counts skew results, and shows that increasing connections alone rarely improves throughput.
The article explains why resource isolation is essential in distributed architectures and details various isolation strategies—including thread, process, cluster, data read/write, static, and crawler isolation—illustrated with Netty, Dubbo, Tomcat examples, code snippets, and a comparison of thread‑pool versus semaphore isolation in Hystrix.
This article introduces the open‑source CIM instant‑messaging system, explains its Netty/WebSocket‑based backend architecture, outlines the available client SDKs and server modules, and showcases functional previews for console, Android, and web clients, guiding developers on how to adopt or adapt the solution.
This article explains various approaches to implementing delayed tasks in backend systems, comparing database polling, Java's DelayQueue, Netty's time wheel, Redis sorted sets and keyspace notifications, and RabbitMQ delayed queues, with detailed code examples and analysis of each method's pros and cons.
This article provides a comprehensive overview of RocketMQ's evolution, core architecture, communication flow, storage mechanisms, flushing strategies, high‑availability synchronization, and transaction message implementation, illustrating each component with diagrams and key source‑code excerpts for developers seeking an in‑depth understanding of the system.
Long Young GC pauses in gRPC/Netty services were traced to Netty’s default thread‑local cache creating many MpscArrayQueue objects, and disabling the cache with the JVM options ‑Dio.netty.allocator.useCacheForAllThreads=false and ‑Dio.grpc.netty.shaded.io.netty.allocator.useCacheForAllThreads=false reduced GC time from up to 900 ms to about 100 ms, stabilizing the service.
Zero-copy techniques eliminate unnecessary data copying between user and kernel space, dramatically improving I/O performance; this article explains core I/O concepts, explores Java implementations like MappedByteBuffer, DirectByteBuffer, channel-to-channel transfers, and demonstrates Netty’s composite buffers, plus examples from Kafka and RocketMQ.
This article explains the architecture, core concepts, routing mechanisms, configuration options, and extensibility of Spring Cloud Gateway, illustrating how it replaces Zuul with a non‑blocking Netty‑based solution and how to customize routes, predicates, filters, and dynamic updates for microservice environments.
This article explains the core differences between Java NIO and traditional IO, introduces channels and buffers, details NIO’s underlying mechanisms, provides a complete code example, and compares NIO’s workflow with Netty’s model, highlighting performance and architectural distinctions.
This article explains the core differences between Java NIO and traditional IO, introduces the concepts of channels and buffers, describes buffer state management, provides a complete NIO selector code example, and compares the NIO workflow with Netty's model.
This article walks through the motivation, core components, technology choices, architecture, and implementation details—including service registration, provider and consumer modules, custom protocol design, serialization, load balancing, and Netty-based I/O—of a self‑written distributed RPC framework, and presents performance test results.
This article provides a detailed English overview of Netty's complete server lifecycle, covering service startup, connection establishment, data read/write handling, business logic processing, and the procedures for closing connections and shutting down the service.
This article traces the real system‑call flow of Java’s I/O models—BIO, NIO, Netty and AIO—on CentOS 7.5, compares their performance, lists advantages and disadvantages, and shows how each model interacts with the Linux kernel via strace.
This article analyzes the actual Linux system calls performed by various Java I/O models—including BIO, NIO, epoll‑based multiplexing, Netty, and AIO—showing code examples, performance trade‑offs, and how each approach interacts with the kernel.
This article explains Netty's role as a mature I/O framework, outlines the end‑to‑end remote‑call workflow of a distributed service, details protocol design, shares performance‑tuning tricks, and presents best practices for building scalable, low‑latency backend systems.
This article explains what Netty is, how to design a distributed service framework using it, details the RPC call flow, discusses protocol design, showcases performance‑boosting features and best practices, and provides deep insights into Netty's architecture, threading model, and low‑level optimizations.
This article explains how to build a scalable long‑connection service using Netty, covering the underlying concepts, Linux kernel tuning, code examples for Java NIO and Netty, performance bottlenecks such as QPS, data‑structure and GC issues, and practical optimization techniques to achieve hundreds of thousands of concurrent connections.
This article explains how using Netty for HTTP handling—covering codec setup, HEAD request support, ByteBuf reference management, connection pooling, and full asynchronous processing—delivers superior performance, lower GC pressure, and better scalability compared to traditional servlet containers.
This article compares several Java-based approaches for implementing delayed tasks, including database polling with Quartz, JDK DelayQueue, Netty's HashedWheelTimer, Redis sorted sets and keyspace notifications, and RabbitMQ dead‑letter queues, analyzing their advantages, disadvantages, and code implementations.
This article breaks down the design and source‑code implementation of RocketMQ's NameServer, detailing its core responsibilities, component interactions, and the seven Java classes that together provide network handling, connection management, routing, configuration, and startup logic.
This article details Ximalaya's evolution of its high‑traffic gateway—from a Tomcat‑based prototype to a fully asynchronous Netty design—covering core features, full‑link timeout handling, monitoring, performance optimizations, and future plans for HTTP/2 and unified downgrade.
This article details a large‑scale C10K performance test of Dubbo, analyzes why service calls time out under thousands of concurrent consumers, identifies heartbeat‑induced Netty thread saturation and TCP full‑connection‑queue overflow as root causes, and presents concrete optimizations that dramatically improve latency and stability.
This article analyzes the C10K scenario where Dubbo‑based services experience massive timeout failures, examines root causes such as heartbeat‑induced Netty thread saturation and TCP backlog overflow, and presents a series of optimizations that dramatically improve latency, CPU usage, and stability in large‑scale deployments.
This article explains how Netty, an asynchronous event‑driven Java NIO framework, simplifies building high‑performance, maintainable network servers and clients by handling I/O, threading, and protocol concerns, and it covers its thread models, zero‑copy techniques, common interview questions, and real‑world use cases such as Dubbo and RocketMQ.
This article explains how Netty, an asynchronous event‑driven network framework built on Java NIO, simplifies the creation of high‑performance, scalable web servers and client components by handling I/O streams, connection management, threading, zero‑copy transfers, and offering flexible reactor thread models for various application scenarios.
This article walks through Dubbo’s RPC encoding and decoding mechanisms, explaining how Netty pipelines add codec handlers, detailing the message header format, exploring Hessian2 serialization, and answering common pitfalls such as class‑path changes and field mismatches.
This article introduces the open‑source CIM instant messaging system, detailing its server‑side architecture based on Netty or Mina, multi‑platform client support (WebSocket, Android, iOS, desktop), core modules, directory structure, and a preview of its console and client interfaces.
This article presents the design, implementation, and performance evaluation of a Netty‑based WebSocket long‑connection gateway that centralizes session management, decouples business logic, supports horizontal scaling, and provides monitoring and alerting for high‑throughput real‑time data push in iQIYI’s platform.
This article explains the concept of zero‑copy, its performance benefits, and how Java NIO, memory‑mapped buffers, direct buffers, channel‑to‑channel transfers, and Netty’s composite buffers implement zero‑copy to reduce data copying between kernel and user space.
This article details the design evolution, architectural choices, performance tuning, monitoring, and future plans of Ximalaya's high‑traffic HTTP gateway, covering its migration from Tomcat NIO to a fully asynchronous Netty implementation and the associated engineering challenges and solutions.
This article explains Netty’s high‑performance asynchronous NIO architecture, introduces the Reactor pattern and its three thread‑model variants, and details Netty’s core components such as Selector, EventLoopGroup, ChannelPipeline, and ByteBuf, highlighting how they improve scalability and efficiency.
This article describes how Ximalaya’s high‑traffic HTTP gateway evolved from a Tomcat NIO + AsyncServlet design to a Netty‑based fully asynchronous architecture, detailing the challenges of blocking I/O, memory copying, GC pressure, and how layered redesign, lock‑free connection pools, comprehensive monitoring, and performance optimizations enabled stable handling of over 200 billion daily calls with peak QPS exceeding 40 k per machine.
This article describes the design, architecture, implementation, and testing of a high‑throughput API gateway built with Spring WebFlux, Netty, and Nacos, covering technology selection, custom routing rules, load‑balancing, service registration, data synchronization, and performance benchmarking.
This article explains why TCP suffers from sticky and unpacked packets, illustrates typical scenarios, outlines four common framing techniques, and shows how Netty's built‑in decoders can be used to reliably solve these issues in high‑performance network applications.
This article explains the challenges of server‑push in HTTP, reviews WebSocket as the mainstream solution, and details the design, implementation, session management, monitoring, and performance testing of a Netty‑based distributed WebSocket long‑connection gateway used at iQIYI.
iQIYI built a Netty‑based WebSocket long‑connection gateway that centralizes session management, uses RocketMQ for cluster‑wide broadcast, provides a simple HTTP push API, scales horizontally to millions of connections, integrates Prometheus/Grafana monitoring, and dramatically cuts development effort for real‑time features such as comments and authentication.
This article walks through the design and implementation of a Java RPC framework, detailing added serialization options, multiple load‑balancing strategies, client‑side service caching, TCP long‑connection handling with Netty, performance testing, and provides the full source code for replication.
This article describes a series of improvements to a Spring‑Boot based Java RPC framework—including support for Protobuf and Kryo serialization, multiple load‑balancing algorithms, client‑side service caching, TCP long‑connection reuse via Netty, and a performance test that reduces request latency by more than tenfold.
An in‑depth guide demonstrates how to combine Netty with Protostuff for high‑performance RPC, detailing serialization setup, custom encoder/decoder implementation, multi‑threading pitfalls, and stress‑testing results that achieve up to 400,000 objects per second per server in a clustered environment.
This article explains the concept of TCP heartbeat, demonstrates how to use Netty's IdleStateHandler to implement client‑server heartbeat detection, and provides a complete Java example with reconnection logic, retry policies, and detailed code snippets for building a robust long‑connection service.
This article presents a practical Netty‑based RPC solution using Protostuff serialization, detailing large‑scale stress testing, performance bottlenecks, and code‑level optimizations that enable handling hundreds of thousands of objects per second reliably.
This article details how to build a high‑performance Netty RPC system using Protostuff for serialization, covering dependency setup, custom encoder/decoder implementation, multithreaded buffer handling, and stress‑test results that achieve hundreds of thousands of objects per second per server.
This article details a systematic investigation of various backend performance problems—including CMS GC delays, biased‑lock revocation, Netty worker thread blocking, and log‑framework overhead—provides root‑cause analysis, JVM tuning parameters, and practical recommendations to mitigate latency spikes in production services.
This article provides a concise, code‑driven walkthrough of Netty's core components—including event‑loop groups, channel initialization, pipeline handling, and the server‑client handshake process—by simplifying the original source to highlight the essential mechanisms behind asynchronous network communication in Java.
This article explains how Netty's boss and worker NioEventLoop threads collaborate to accept socket connections, register selectors, and transition to read operations, detailing the underlying selector polling, OP_ACCEPT handling, and the code paths that trigger channel activation.
This article explains how Netty creates and uses the main thread, boss thread, and worker threads through NioEventLoopGroup and selectors, detailing the initialization of ServerSocketChannel, event registration, and the transition from OP_ACCEPT registration to active listening.
This guide explains how Netty handles encoding and decoding, covering abstract decoder classes, concrete implementations like ByteToMessageDecoder, ReplayingDecoder, fixed‑length and line‑based decoders, and essential reference‑count management for building robust network applications.
This article explains why TCP experiences sticky and half packets, analyzes the underlying causes such as buffer size mismatches and MTU limits, and presents practical solutions including short connections, fixed‑length framing, delimiter‑based framing, and length‑field framing, with their advantages and trade‑offs.
Zero-copy techniques eliminate unnecessary data copying between user and kernel space, dramatically improving I/O performance; this article explains core concepts, Java NIO’s MappedByteBuffer and DirectByteBuffer, channel-to-channel transfers, Netty’s composite buffers, and how frameworks like Kafka and RocketMQ leverage zero-copy.
This tutorial provides a detailed introduction to Netty, covering its architecture, core concepts such as buffers, channels, selectors, reactor thread models, zero‑copy techniques, and includes practical TCP server/client code examples, helping readers understand and apply Netty for high‑performance Java network programming.
This article describes how the author investigated recurring errors in a Java-based lecture hall system, identified thread pool leaks caused by improper use of AsyncHttpClient, and resolved the issue through command‑line diagnostics, code fixes, and system monitoring, improving stability.
This article details the design and implementation of a Java chat system that uses Netty for server‑side networking, Swing for the client UI, and MySQL with C3P0 for data persistence, covering features such as user authentication, friend management, single‑chat messaging, and online status detection.
This article presents a comprehensive walkthrough of a Java chat application built with Netty for server‑side communication and Swing for the client UI, detailing functional features such as password, nickname, and signature updates, friend management, single‑chat messaging, online status detection, and includes full source code snippets and execution screenshots.
This article details the process of adapting the Netty MQTT codec to the t‑io framework, covering the migration from MQTT 3.1.1 to MQTT 5, code adjustments, ByteBuf-to-ByteBuffer conversion, custom WriteBuffer handling, and the resulting client demonstrations.
This article explains the fundamentals of traditional socket programming and compares it with Netty's architecture, covering server and client components, HTTP request handling steps, Netty's NioEventLoop, Channel, ByteBuf, Pipeline, and unsafe implementations, all illustrated with diagrams and code snippets.
This article explains Netty's thread model, covering the evolution from simple Thread usage to Executor‑based pools, the design of the EventLoop interface, task scheduling mechanisms, differences between Netty 3 and Netty 4, and how thread allocation and ThreadLocal affect performance and scalability.
This article demonstrates how to combine Spring Boot and Netty, define a .proto file, generate Java classes with protoc, configure Maven dependencies, and implement both server and client handlers to exchange binary Protobuf messages with heartbeat and reconnection logic.
This article revisits memory allocation and reclamation concepts by examining Java's Netty memory pool implementation, its theoretical basis in jemalloc, and practical design choices such as arena allocation, thread‑local caches, pool chunks, sub‑pages, and multi‑threaded performance considerations.