libevent icon indicating copy to clipboard operation
libevent copied to clipboard

support priority for evdns

Open smzgl opened this issue 7 years ago • 7 comments

event and bufferevent has already support priority, buf evdns not. And evdns has a low priority by default. it is a problem while prog has a huge count of new connection and old connection.

smzgl avatar Nov 26 '18 09:11 smzgl

event and bufferevent has already support priority, buf evdns not

This can be interesting in general.

And evdns has a low priority by default

it is not low, it has default priority, and this half of the available priorities (IOW it is in the middle)

it is a problem while prog has a huge count of new connection and old connection.

and you want to rule priorities for the new/old connections? can you elaborate this a little bit more?

azat avatar Nov 27 '18 22:11 azat

yes, you are right, default priority is half of the available priorities.

in my case, server have 600k+ outgoing connection, they are use domain names to connect to different host. somewhy, udp recv buffer default size is very small. server must handle dns response as quickly as possible, or the incoming dns response may be dropped when server too busy.

event has default priority in most 3rd library. now i cant set up event priority for 3rd libraay, evdns, and i cant set up udp recv size of dns client in evdns.

smzgl avatar Dec 02 '18 05:12 smzgl

in my case, server have 600k+ outgoing connection, they are use domain names to connect to different host

And this is one process or not? I guess no, since I don't think that one process can handle that match requests per second. So I would strongly suggest you decrease amount of connections per-thread, since I'm not sure that priorities will help you (although I'm not against adding them to evdns)

And sounds like you are using client side of evdns.

udp recv buffer default size is very small

Do you have any profiling data that will confirm buffer size problem?

event has default priority in most 3rd library. now i cant set up event priority for 3rd libraay, evdns, and i cant set up udp recv size of dns client in evdns.

Not sure that I follow this, but maybe as a temporary fix increasing defaults will help? i.e.:

sysctl -w net.ipv4.udp_wmem_min=$((4096<<2))
sysctl -w net.ipv4.udp_rmem_min=$((4096<<2))
sysctl -w net.ipv4.udp_mem= # adjust according to available memory that you have

azat avatar Dec 02 '18 14:12 azat

all connection work in one process, but not one thread. and the connections not always send request. so server it works well so far, except dns query.

it is usefull to increase udp default buffer size, but i can not modify that setttings at product environment for some reasons. ex: hardware limits, some software limits, permission and so on.

so if i can get fd of evdns client, or set evdns priority, than i could invoke setsockopt to increase udp buffer size and invoke event_config_set_max_dispatch_interval to ensure dns reponse be processed as quickly as prossible.

now, i hack source code of libevent to increase two interface, evdns_base_nameservers_getfd and evdns_base_set_priority, and problem has been resolved. but it has a bad maintainability.

smzgl avatar Dec 03 '18 10:12 smzgl

all connection work in one process, but not one thread. and the connections not always send request. so server it works well so far, except dns query.

So how much dbs queries do you have per second?

now, i hack source code of libevent to increase two interface, evdns_base_nameservers_getfd and evdns_base_set_priority, and problem has been resolved. but it has a bad maintainability.

If you can transform your changes into a patch with a regression tests (regress_dns.c) and real numbers from your workload, that would be great!

azat avatar Dec 03 '18 19:12 azat

So how much dbs queries do you have per second?

although this is not that interesting (since there are a lot of other events)

azat avatar Dec 03 '18 19:12 azat

actually, in my environment:

cat /proc/sys/net/ipv4/udp_mem 2955 3942 5910

if dns query above 200~800 per second, less then 10 dns queries would timeout. sometimes 500 or so new connections are suddenly created. at this time, the probability of a DNS request timeout increases dramatically.

smzgl avatar Dec 04 '18 15:12 smzgl