cubicdaiya / ngx_dynamic_upstream

Dynamic upstream for nginx
Other
501 stars 108 forks source link

Some questions about ngx_dynamic_upstream_op_remove functions #7

Closed wangfakang closed 8 years ago

wangfakang commented 9 years ago

Hi @cubicdaiya Fisrst: I have some questions about ngx_dynamic_upstream_op_remove functions that call op_remove function at the time there are a lot of request using the backend server(may be keepalive) , as the old request end will do some thing for the server but the server has been removed. So this time will be no problem? what do you thank may be Im wrong.

Second: When we operate Shared memory should be locked ?

Thank you.

cubicdaiya commented 9 years ago

@wangfakang

First:

It should be no problem. If there is some problem, it is a bug.

Second:

Yes. See the block below about details.

https://github.com/cubicdaiya/ngx_dynamic_upstream/blob/master/src/ngx_dynamic_upstream_module.c#L172-#L184

wangfakang commented 9 years ago

@cubicdaiya Thank you for your prompt response. Use lock way may be have a certain influence on its performance. In a other way each worker copy upstream memory may be performance good but waste of memory.

cubicdaiya commented 9 years ago

@wangfakang

Use lock way may be have a certain influence on its performance.

The lock is not a panacea. But I believe it is the better approach in this case.

In a other way each worker copy upstream memory may be performance good but waste of memory.

Unfortunately, the approach above does not have no way to update upstreams for all worker porcesses at a time.

wangfakang commented 9 years ago

@cubicdaiya Oh, i see. Thank you for your detailed explanation.

mscbg commented 5 years ago

I think there may be some problems here. 'ngx_http_upstream_get_round_robin_peer' will get pointer to sockaddr in peer . When we remove server, connection refered to this server will get a wild pointer to sockaddr. Lock is useless. @wangfakang @cubicdaiya