Stress testing: doing something as quickly as possible at the "same time"

Hello, this is my first post, and I hope it isn’t already obviously answered in another post. I did my best to look.

Problem statement

I want to do something as quickly as possible at the “same time” (as possible). To simplify the realm of possibilities, let’s say I’m using :gen_tcp to send a packet.

What I do and don’t know

I know:

  • :gen_tcp is process-less and returns a Port
  • Some strategies for spawning large numbers of processes such as using PartitionSupervisor to spawn a DynamicSupervisor per CPU core

I don’t know:

  • How to handle ports (or what they are really in the context of a network socket)
    • Should I make one per CPU core, one per worker process, or something in-between?
    • Is NimblePool relevant here (can’t tell from the README)
    • Can I have multiple TCP connections/session per port?
  • How to signal to all workers to do something at the same time
    • How can I do this without causing a signal sender bottleneck? Can Phoenix PubSub cover this? Is there a simpler approach without building a bespoke pubsub myself?

Additional notes on what I want:

  • To make as many TCP socket connections as possible to more closely represent independent client connections

Context (not required reading)

I want to build a stress testing tool in Elixir that will be used against transports HTTP1.x and websockets. The point is to test the efficiency/throughput differences between the two approaches.

I know there’s a difference between the two transports in that the former is non-stateful and latter stateful, but I do want to be fair to HTTP1.x and use keep-alive; so maybe my request implementation can be similar-ish for a more apples-to-apples comparison.

2 Likes