Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SO_REUSEPORT support to socket #396

Merged
merged 1 commit into from
Oct 6, 2022

Conversation

ton31337
Copy link

@ton31337 ton31337 commented Aug 4, 2015

Add SO_REUSEPORT support to socket. Introduce new feature for Twemproxy running on newer kernels. With this feature you are able to do upgrades, restarts without any downtime. Kernel does load balancing between processes with the same host:port pairs.

@ton31337 ton31337 force-pushed the feature/add_socket_reuseport branch from 655bb94 to 232648b Compare August 4, 2015 19:39
src/nc_stats.c Outdated
@@ -827,7 +828,9 @@ stats_listen(struct stats *st)
log_error("socket failed: %s", strerror(errno));
return NC_ERROR;
}

#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ton31337 twemproxy can run on mac or freebsd also. so I think you should check other os too not only linux :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@charsyam 👍 of course will fix this, but need to be sure if it's worth to spend more time. I mean if it's planned to be merged or not.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@charsyam are you able to test this on FreeBSD ? :)

@ton31337 ton31337 force-pushed the feature/add_socket_reuseport branch 3 times, most recently from daccbb6 to 0ac411f Compare August 17, 2015 17:52
@manjuraj
Copy link
Collaborator

manjuraj commented Oct 1, 2015

change looks great - i need to test this before merging.

@ofirule
Copy link

ofirule commented Nov 23, 2015

+1
we also implemented the same feature: #435
Just noticed your pull request

@ton31337 ton31337 closed this Oct 5, 2018
@ton31337 ton31337 deleted the feature/add_socket_reuseport branch October 5, 2018 13:30
@ton31337 ton31337 restored the feature/add_socket_reuseport branch September 27, 2022 07:51
@ton31337 ton31337 reopened this Sep 27, 2022
@CLAassistant
Copy link

CLAassistant commented Sep 27, 2022

CLA assistant check
All committers have signed the CLA.

@ton31337
Copy link
Author

@manjuraj ping

src/nc_util.c Show resolved Hide resolved
src/nc_util.c Outdated Show resolved Hide resolved
src/nc_proxy.c Outdated Show resolved Hide resolved
src/nc_stats.c Show resolved Hide resolved
src/nc_util.c Outdated Show resolved Hide resolved
Introduce new feature for Twemproxy running on newer kernels. With this
feature you are able to do upgrades, restarts without any downtime. Kernel
does load balancing between processes with the same host:port pairs.

Also, helps running on more than single core.

Signed-off-by: Donatas Abraitis <donatas@hostinger.com>
@TysonAndre
Copy link
Collaborator

TysonAndre commented Sep 28, 2022

change looks great - i need to test this before merging.

This seems to work locally - testing since I haven't used SO_REUSEPORT elsewhere. I can start two nutcracker instances for memcached with reuseport: true and

  • stats ports are shared and go to one of the two instances (unrelated to the config file setting for individual pools)
  • New connections are shared and go to one of the two instances
  • Connections stay connected to the same instance

@TysonAndre TysonAndre merged commit 60aaf85 into twitter:master Oct 6, 2022
@ton31337 ton31337 deleted the feature/add_socket_reuseport branch October 6, 2022 05:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants