networking - What are some tips for buffer usage and tuning in custom TCP services? -


I am researching many types of networking libraries and frameworks such as libevent, libev, facebook ternado, and symmetry (Python ).

One thing I see in their implementation, application-level per-client read / write buffers (such as Iostream in Tornado) are used - even such buffers in Haproxy Are there.

In addition to these application-level buffers, OS kernel tcp implementation buffers per socket.

I understand the use of buffer's app / lib: App / Libill reads out of buffer, does something with app buffer and app data (for example, a message in it deserillise

However, I have confused myself about the need / use of writing a buffer. Why not only send / send buffer to kernel? Is this system to avoid overhead of call (written)? I think the kernel should be ready to write the buffer with more data, when the kernel shows the App / Lib that the socket is "writable" (like the EPOlout) but, not just with the app writing buffer Why do so far and configure Kernel's TCP write buffer to be equally larger?

Also, consider a service for which disabling the nagging algorithm (i.e. game server). In such a configuration, I think I want to contradict: writing a kernel is not a buffer, but an application buffer, yes? When the app is ready to send a complete message, then he sends an apa buffer (), and writes the kernel and passes through it.

If you want, thank you!

OK, there is no difference between talking to apricot, reading and writing buffer, one Buffer is used for both purposes, which protects the copy, however, it is really painful to make some changes. For example, sometimes you have to rewrite an HTTP header and you will have to rewrite your To manage the data correctly, you have to manage, and Some position will be saved about the value of the cheat header. In Haaproxy, the connection header can be rewritten, and its previous and new states are saved because they need to be written after re-writing, later on. Using a reading and writing buffer, you do not have this complexity, because you can always look back in your reading buffer if you need any basic data.

Hyproxy is also able to use intermediate partition chairs on Linux This means that it is not read and write, it just tells the kernel where to take it, and where to take it Have to go Then the kernel then automatically transmits pointers without any copy, which copies the data from the network card to the second place (when possible) to transfer the TCP sections, but then the data is not transferred to the user location This is done, thus avoid double copy.

It is completely true about the fact that you do not normally need to copy the data between the buffer. It is a waste of memory bandwidth on the HPCA splicing with 20% CPU at 10 Gbps Runs, but without splicing (2 more copies), it's about 100% but then consider the complexity of the options, and make your choice.

This is hoping.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -