第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會有你想問的

請問這樣算3千的并發(fā)嗎?

請問這樣算3千的并發(fā)嗎?

回首憶惘然 2019-01-05 21:20:23
問題描述同一個(gè)ip下用3千個(gè)線程去請求,而真實(shí)場景是3千個(gè)不同的ip,前一種情況可以復(fù)用socket,似乎真實(shí)場景要更慢,有辦法模擬嗎?相關(guān)代碼并發(fā)測試代碼import requestsimport timeimport threading s=time.time() def get():     r=requests.get('http://localhost:3000?id='+str(i))     #print(threading.currentThread())     #print(r.text)for i in range(1,3000):     threading.Thread(target=get).start()print(time.time()-s)服務(wù)端代碼,,寫入3000條數(shù)據(jù),用時(shí)11秒左右,1000條則是3秒左右,有辦法優(yōu)化嗎?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)
查看完整描述

1 回答

?
眼眸繁星

TA貢獻(xiàn)1873條經(jīng)驗(yàn) 獲得超9個(gè)贊

這叫個(gè)錘子并發(fā)

查看完整回答
反對 回復(fù) 2019-01-05
  • 1 回答
  • 0 關(guān)注
  • 553 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號