Erlang can be used to write highly scalable parallel applications. Millions of lightweight components are often displayed, which are called actor similar to thread components. Unfortunately, this often requires you to use Erlang, a relatively mysterious programming language, to rewrite all the code. However, we also have other options, such as the development of a well-known CCR platform developed by the. NET robot department.
As an Actor-based language, Erlang achieves high concurrency through the Actor model. In this model, the most basic Parallel unit is not a thread or fiber, but a more lightweight thing. As a "process" in Erlang, each parallel unit occupies only about 1200 bytes of basic resources in a 32-bit system. In contrast, by default, every thread in the Windows operating system allocates 1 MB space on the stack. In addition, additional space is required for Bookkeeping and local thread storage. Because it is very lightweight, an application easily supports millions of processes for concurrent processing.
At any time, most processes are idle. When a process receives a message, the running platform assigns it a thread to respond to the message. A response may create a new process, send messages to other processes, or change its status. Once the message is processed, the process will die or wait for the next message.
The message processing system achieves high-end concurrency and high performance. Each message is sent asynchronously, making processes highly independent of each other. The platform can use messages to determine which process to wake up. Since each process can be processed by any thread, context switching operations that are relatively expensive can be greatly reduced.