Replies: 4 comments
-
1st tip: use coroutines, easier to read . |
Beta Was this translation helpful? Give feedback.
-
for every port, you need to call listen & accept on each shard; at least shard 0 must listen on all ports (because under the hood, all connections are accepted on shard0, and then xferred to the actual target shard) |
Beta Was this translation helpful? Give feedback.
-
Thanks, @niekbouman — this did the trick. I had shard 0 listen on all ports and mapped each shard to its respective port. With fixed_cpu load balancing enabled, everything worked smoothly. I’m drafting an article to share these learnings with the community and will post it here soon. |
Beta Was this translation helpful? Give feedback.
-
Here is the sample code https://github.com/somesh-m/seastar-samples/tree/master/all_shard_listener |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I’m trying to start a per-shard TCP listener in Seastar, where each shard binds to its own port (6010 + shard_id).
On shard 0, everything works — the listener binds and accepts connections fine.
But on other shards, the listener either exits silently or never shows as bound.
No exceptions are thrown, and the accept loop doesn’t seem to run. I had earlier used keep_doing but then changed to repeat just to make sure accept loop retries. Has anyone faced the same issue. Assuming this is possible to do, please help me out.
The specific use case is that I want to send requests to a particular shard based on a hash function. Since Seastar doesn’t provide a direct way to route incoming network requests to a specific shard, I’m experimenting with port-based routing, where each shard listens on a unique port representing its shard ID.
Here is the sample code used:
OS: Ubuntu 24.04.3 LTS
Comand used:
sudo strace -ff -ttT -e trace=bind,listen,accept -o strace.log ./testsocket --smp 2
Things I’ve already checked
cat strace.log.36918 07:06:15.075703 bind(13, {sa_family=AF_INET, sin_port=htons(6010), sin_addr=inet_addr("0.0.0.0")}, 16) = 0 <0.000014> 07:06:15.075809 listen(13, 100) = 0 <0.000010>
Expected Behaviour:
Each shard should independently bind to a unique TCP port (6010 + shard_id) and stay in an active accept loop.
For example, on an 8-core setup (--smp=8), the following should occur:
Shard 0 → Port 6010
Shard 1 → Port 6011
Shard 2 → Port 6012
…
Shard 7 → Port 6017
Beta Was this translation helpful? Give feedback.
All reactions