-
Notifications
You must be signed in to change notification settings - Fork 0
Basic Network Knowledge
Hyfrankl edited this page Mar 12, 2024
·
2 revisions
- Concept: DMA allows certain hardware devices to access system memory directly without involving the CPU, improving efficiency and performance.
- Important for high-speed data transfer operations, such as network and disk I/O.
- Concept: Zero-copy techniques enable data transfer between kernel space and user space without redundant memory copying. No copy to user space.
- mmap + write: Memory mapping from kernel to user space.
- sendfile (DMA + SG-DMA): Uses DMA and scatter-gather DMA (SG-DMA) to transfer data directly from disk to network without copying to user space.
- Concept: Asynchronous I/O allows I/O operations to be executed concurrently without blocking the calling process or thread.
- Important for improving concurrency and responsiveness in I/O-bound applications.
- Concept: A thread pool is a collection of pre-created threads that can be reused for executing tasks, improving performance and resource utilization.
- Important for handling concurrent requests efficiently in server applications.
- Concept: select and poll are system calls used for multiplexed I/O, allowing a process to monitor multiple file descriptors for readiness.
- Important for handling I/O events in a scalable and efficient manner, but can be limited in handling large numbers of file descriptors.
- Concept: epoll is a more scalable and efficient alternative to select and poll for multiplexed I/O in Linux.
- Important for handling large numbers of concurrent connections and events in high-performance server applications.
- Refer to this
- Concept: A software interrupt is requested by the processor itself upon executing particular instructions or when certain conditions are met. Every software interrupt signal is associated with a particular interrupt handler.
- Edge-triggered vs. Level-triggered: once vs. rolling
- To address the issues of interrupt handlers taking too long to execute and interrupt loss, the interrupt handling process is divided into two phases: the "top half" and the "bottom half."
- The top half is used for quickly handling interrupts. It typically disables interrupt requests temporarily and is primarily responsible for handling hardware-related or time-sensitive tasks.
- The bottom half is used for deferring the unfinished work from the top half and generally runs in the form of a "kernel thread."
- Concept: The Reactor pattern is based on synchronous I/O operations (non-block).
- It uses a single thread or a thread pool to handle multiple concurrent connections or events.
- The Reactor component (also called the Demultiplexer) monitors and dispatches events (such as incoming connections or data) to the appropriate event handlers.
- Event handlers are responsible for processing the events and performing the necessary operations.
- The main advantage of the Reactor pattern is its simplicity and the ability to handle a large number of concurrent connections with a small number of threads.
- Netty vs. Nginx
- The Proactor pattern is based on asynchronous I/O operations. It uses a separate thread or thread pool for each connection or operation, allowing for concurrent execution of I/O operations. The Proactor component initiates asynchronous I/O operations and associates them with completion handlers. When an I/O operation completes, the corresponding completion handler is invoked to process the result. The main advantage of the Proactor pattern is that it can achieve better scalability and concurrency by avoiding the need for explicit thread management and context switching.