Excuse me, is this a concurrency of 3000?

problem description

it takes 3, 000 threads to request under the same ip, but the real scenario is 3, 000 different ip,. In the former case, socket, can be reused. It seems that the real scenario is slower. Is there any way to simulate it?

related codes

concurrent test code

import requests
import time
import threading
s=time.time()
def get():
    r=requests.get("http://localhost:3000?id="+str(i))
    -sharpprint(threading.currentThread())
    -sharpprint(r.text)
for i in range(1,3000):
    threading.Thread(target=get).start()
print(time.time()-s)    

server code, it takes about 11 seconds to write 3000 pieces of data, and 1000 takes about 3 seconds. Is there any way to optimize it?

var http = require("http");
var url =require("url")
var mysql      = require("mysql");
var connection = mysql.createConnection({
  host     : "localhost",
  user     : "root",
  password : "root",
  database : "test"
});
 
connection.connect();

http.createServer(function(req, res){
    //res.writeHead(200, {"Content-Type": "text/plain"});
    id=url.parse(req.url, true).query.id;
    connection.query("INSERT INTO speed(num) values ("+id+")")
    //connection.query("select id from speed where num="+id)
}).listen(3000)

it's called a hammer concurrency

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bde85c-31423.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bde85c-31423.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?