<h1>Linux, without docker</h1>

<p>In Linux, you can create arbitrarily many IP address for each interface. A comment in <a href="https://serverfault.com/questions/328146/max-number-virtual-ip-addresses-per-nic">https://serverfault.com/questions/328146/max-number-virtual-ip-addresses-per-nic</a> reports success with 2000, and hearsay of 5000 successful IPs.</p>

<p>So. Pick any Linux box on your intranet, which could of course be a VM, and create as many IPs on its single ethernet interface (MAC address) as you wish.</p>

<p>Say you're using the 10.0.0.0/8 private network, then you can execute lots of these:</p>

<pre><code>ifconfig eth0:1 10.0.0.2 netmask 255.0.0.0
ifconfig eth0:2 10.0.0.3 netmask 255.0.0.0
...
ifconfig eth0:260 10.0.1.6 netmask 255.0.0.0
...
</code></pre>

<p>You should be able to use <code>curl --interface eth0:3</code> (or maybe <code>--interface 10.0.0.3</code>) to use a specific source address. For <code>wget</code>, it's <code>--bind-address=10.0.0.3</code> etc. Start the curls in the background ("&amp;") and they will run more or less concurrently - or look for some test driver (different question) to run them for you.</p>

<p>This will give you lots of requests from separate IP addresses, but all conveniently running on one machine.</p>

<h1>Docker, trivially</h1>

<p>With docker: just make an image, as small as humanly possible, which connects to your server. You can use <code>curl</code> without any special options.</p>

<p>Then fire up your 1000 docker containers, just like you usually would. Each will automatically get an IP address on the internal docker network (172.x.0.0/16 by default).</p>

<p><a href="https://stackoverflow.com/questions/21799382/is-there-a-maximum-number-of-containers-running-on-a-docker-host">https://stackoverflow.com/questions/21799382/is-there-a-maximum-number-of-containers-running-on-a-docker-host</a> indicates that it is possible with hardware that is not too uncommon today; a naive 1000 docker containers used roughly 3 GB of RAM for them. That question also has some hints on options you can use to decrease the memory needs. Aside from memory, there won't be too much overhead, i.e. CPU wise it should comparable.</p>

<h1>Docker, with special networking</h1>

<p><code>docker network</code> opens up manually created networking for you. You should be able to cobble something together (just check the individual <code>--help</code> pages, it's all pretty self explanatory), and combine that with the <code>ifconfig</code> approach explained above. This would mean that you only need one container for your <code>curl</code>s, and start 1000's of them inside that container.</p>

<p>I would try to just run your 1000 containers, first, though, unless you are limited in the RAM department, for ease of use.</p>

<h1>About the <code>curl</code>...</h1>

<p>Whatever you do, don't just start a single <code>curl</code> in each instance, but have each runner be an endless loop of back-to-back <code>curl</code> calls. This way, you avoid long gaps inbetween where your individual jobs are being started and stopped; this is obviously especially important for the "1000 docker containers" variation. In the answer linked above, they note that it took them some good amount of minutes to start up those thousands of containers, so you do not want to do that over and over again.</p>

<p>And you might as well get rid of <code>curl</code> altogether and create small networking app in the language of your choice (Perl, Ruby, C, Java...) to avoid process startup overhead.</p>

CC BY-SA 3.0
2018-04-14T15:49:16.060Z
To get a better distribution in case 1, gatling could be a solution also. Beware that a single machine will hardly make more simultaneous requests than its number of core, deferring network io to the ethernet card may help a little but I doubt the 1k request will be simultaneous (probably not a problem but it worth being said I think)
Tensibai
CC BY-SA 3.0
2018-04-14T19:09:57.343Z
@Tensibai, I assume the question is not so much about having traffic comparable to 1000 real users, but literally about testing the capability of some special program to keep track of 1000 IPs... whatever that may be good for. But I'll put in a note about doing loops instead of one-offs for the `curl` processes so it's more likely to get a lot of concurrent requests by avoid the setup overhead.
AnoE
CC BY-SA 3.0
2018-04-15T07:50:11.563Z
@AnoE Thanks! Just to add to the disscusion: It is both about traffic and about IPs. servers (TCP stacks) behave different when there are 1000 requests from one IP or 1000 IP each making 1 request.
nmnir
CC BY-SA 3.0
2018-04-14T14:12:17.697Z
2018-04-15T08:00:41.267Z
2018-04-15T08:00:41.267Z
AnoE
<p>I need to simulate many connections. Currently using curl.
What is the best way to deploy thousands of such requests with different IPs using some script?</p>

CC BY-SA 3.0
2018-04-14T07:16:25.637Z
What did you try?
030
CC BY-SA 3.0
2018-04-14T08:06:21.817Z
I don't know much about microservices and dockers. currently only one machine starting many requests but all requests are with the same IP.
nmnir
CC BY-SA 3.0
2018-04-15T09:43:51.850Z
Have you looked at Kubernetes?
dwjohnston
CC BY-SA 3.0
2018-04-15T12:43:22.517Z
@dwjohnston  why Kubernetes should be better compared with the other suggestions?
nmnir
CC BY-SA 3.0
2018-04-15T21:40:21.797Z
Could you clarify what you're trying to achieve? Is this for a load balancing/stress test?
dwjohnston
CC BY-SA 3.0
2018-04-16T16:37:17.810Z
Yes, for stress testing load balancer/server
nmnir
<docker><microservices>
Making thousands of microservice/dockers with different IPs
nmnir
# Making thousands of microservice/dockers with different IPs

(Asked by: username_0 on 2018-04-13)

I need to simulate many connections. Currently using curl.
What is the best way to deploy thousands of such requests with different IPs using some script?

**Tags:** docker, microservices

> **Comments:**
> **username_1**: What did you try?  
> **username_0**: I don't know much about microservices and dockers. currently only one machine starting many requests but all requests are with the same IP.  
> **username_2**: Have you looked at Kubernetes?  
> **username_0**: @username_2  why Kubernetes should be better compared with the other suggestions?  
> **username_2**: Could you clarify what you're trying to achieve? Is this for a load balancing/stress test?  
> **username_0**: Yes, for stress testing load balancer/server  

---

## 1 answers

### Answer by username_3 on 2018-04-14. Score: 6 | Accepted answer

Linux, without docker
In Linux, you can create arbitrarily many IP address for each interface. A comment in https://serverfault.com/questions/328146/max-number-virtual-ip-addresses-per-nic reports success with 2000, and hearsay of 5000 successful IPs.
So. Pick any Linux box on your intranet, which could of course be a VM, and create as many IPs on its single ethernet interface (MAC address) as you wish.
Say you're using the 10.0.0.0/8 private network, then you can execute lots of these:
ifconfig eth0:1 10.0.0.2 netmask 255.0.0.0
ifconfig eth0:2 10.0.0.3 netmask 255.0.0.0
...
ifconfig eth0:260 10.0.1.6 netmask 255.0.0.0
...

You should be able to use curl --interface eth0:3 (or maybe --interface 10.0.0.3) to use a specific source address. For wget, it's --bind-address=10.0.0.3 etc. Start the curls in the background ("&") and they will run more or less concurrently - or look for some test driver (different question) to run them for you.
This will give you lots of requests from separate IP addresses, but all conveniently running on one machine.
Docker, trivially
With docker: just make an image, as small as humanly possible, which connects to your server. You can use curl without any special options.
Then fire up your 1000 docker containers, just like you usually would. Each will automatically get an IP address on the internal docker network (172.x.0.0/16 by default).
https://stackoverflow.com/questions/21799382/is-there-a-maximum-number-of-containers-running-on-a-docker-host indicates that it is possible with hardware that is not too uncommon today; a naive 1000 docker containers used roughly 3 GB of RAM for them. That question also has some hints on options you can use to decrease the memory needs. Aside from memory, there won't be too much overhead, i.e. CPU wise it should comparable.
Docker, with special networking
docker network opens up manually created networking for you. You should be able to cobble something together (just check the individual --help pages, it's all pretty self explanatory), and combine that with the ifconfig approach explained above. This would mean that you only need one container for your curls, and start 1000's of them inside that container.
I would try to just run your 1000 containers, first, though, unless you are limited in the RAM department, for ease of use.
About the curl...
Whatever you do, don't just start a single curl in each instance, but have each runner be an endless loop of back-to-back curl calls. This way, you avoid long gaps inbetween where your individual jobs are being started and stopped; this is obviously especially important for the "1000 docker containers" variation. In the answer linked above, they note that it took them some good amount of minutes to start up those thousands of containers, so you do not want to do that over and over again.
And you might as well get rid of curl altogether and create small networking app in the language of your choice (Perl, Ruby, C, Java...) to avoid process startup overhead.

> **Comments:**
> **username_4**: To get a better distribution in case 1, gatling could be a solution also. Beware that a single machine will hardly make more simultaneous requests than its number of core, deferring network io to the ethernet card may help a little but I doubt the 1k request will be simultaneous (probably not a problem but it worth being said I think)  
> **username_3**: @username_4, I assume the question is not so much about having traffic comparable to 1000 real users, but literally about testing the capability of some special program to keep track of 1000 IPs... whatever that may be good for. But I'll put in a note about doing loops instead of one-offs for the `curl` processes so it's more likely to get a lot of concurrent requests by avoid the setup overhead.  
> **username_0**: @username_3 Thanks! Just to add to the disscusion: It is both about traffic and about IPs. servers (TCP stacks) behave different when there are 1000 requests from one IP or 1000 IP each making 1 request.  

---

