成人国产在线小视频_日韩寡妇人妻调教在线播放_色成人www永久在线观看_2018国产精品久久_亚洲欧美高清在线30p_亚洲少妇综合一区_黄色在线播放国产_亚洲另类技巧小说校园_国产主播xx日韩_a级毛片在线免费

資訊專(zhuān)欄INFORMATION COLUMN

Swoole 同步模式與協(xié)程模式的對(duì)比

WilsonLiu95 / 1051人閱讀

摘要:開(kāi)始測(cè)試是一個(gè)基于的常駐內(nèi)存協(xié)程三模高性能框架,由于該框架同時(shí)具備常駐內(nèi)存模式協(xié)程模式,所以能很方便的測(cè)試結(jié)果。常駐內(nèi)存模式的進(jìn)程數(shù)配置過(guò)多,并發(fā)性能反而會(huì)降低,該問(wèn)題同樣適用于傳統(tǒng)模式。

在現(xiàn)代化 PHP 高級(jí)開(kāi)發(fā)中,Swoole 為 PHP 帶來(lái)了更多可能,如:常駐內(nèi)存、協(xié)程,關(guān)于傳統(tǒng)的 Apache/FPM 模式與常駐內(nèi)存模式(同步)的巨大差異,之前我做過(guò)測(cè)試,大家能直觀的感受到性能的巨大提升,但是協(xié)程到來(lái)后,又帶來(lái)了多少性能的提升呢?提升的又是哪方面的性能?下面逐步測(cè)試一下。

傳統(tǒng)的 Apache/FPM 模式與常駐內(nèi)存模式(同步)的測(cè)試文章:
MixPHP 并發(fā)性能全面對(duì)比測(cè)試

協(xié)程的優(yōu)勢(shì)

協(xié)程模式與常駐內(nèi)存模式(同步)/傳統(tǒng)模式相比:

常駐模式/傳統(tǒng)模式都屬于同步阻塞編程,由于同一個(gè)進(jìn)程不能并行處理請(qǐng)求,所以為了提高并發(fā),只能開(kāi)啟更多的進(jìn)程,通常超過(guò) 100 甚至更多,每個(gè)進(jìn)程都有基礎(chǔ)的內(nèi)存消耗,加起來(lái)就很多了,而且受限于 Linux 總進(jìn)程數(shù)限制,并發(fā)總數(shù)無(wú)法突破,加上進(jìn)程非常多之后,CPU 需要更多的線程切換,浪費(fèi)了很多性能,當(dāng)然相比 FPM 的傳統(tǒng)模式每次都需從頭開(kāi)始,常駐模式還是要好非常多的,但是協(xié)程顯然更加優(yōu)秀。

協(xié)程模式的執(zhí)行方式:

協(xié)程模式中一個(gè)進(jìn)程可以同時(shí)執(zhí)行 N 個(gè)請(qǐng)求,但同一時(shí)刻只執(zhí)行其中的某一個(gè)請(qǐng)求,也就是說(shuō),當(dāng)執(zhí)行到 MySQL/Redis 這些客戶(hù)端時(shí),由于需要等待客戶(hù)端響應(yīng),常駐模式/傳統(tǒng)模式通常是在傻傻的等待響應(yīng),而協(xié)程這個(gè)時(shí)候會(huì)掛起當(dāng)前協(xié)程,切換到其他協(xié)程中去處理其他請(qǐng)求,所以協(xié)程能同時(shí)處理 N 個(gè)請(qǐng)求,每增加一個(gè)請(qǐng)求只需增加一些內(nèi)存消耗,相比增加一個(gè)進(jìn)程的內(nèi)存消耗,顯然是少太多的,由于協(xié)程能并行處理,所以通常只需配置于 CPU 數(shù)量 1~2 倍左右的進(jìn)程數(shù)即可,更少的進(jìn)程帶來(lái)更少的 CPU 線程切換,又減少很多性能損耗。

開(kāi)始測(cè)試

MixPHP 是一個(gè)基于 Swoole 的FPM、常駐內(nèi)存、協(xié)程三模 PHP 高性能框架,由于該框架同時(shí)具備常駐內(nèi)存模式、協(xié)程模式,所以能很方便的測(cè)試結(jié)果。

測(cè)試環(huán)境:

docker 容器,限制只能使用 1 CPU。

其他參數(shù)如下:

Server      Name:      mix-httpd
Framework   Version:   1.1.0-RC
PHP         Version:   7.2.9
Swoole      Version:   4.1.0
Listen      Addr:      127.0.0.1
Listen      Port:      9501

代碼:

模擬常用的 HTTP 開(kāi)發(fā)需求,執(zhí)行三個(gè) SQL 請(qǐng)求。

// 默認(rèn)動(dòng)作
public function actionIndex()
{
    PDO::createCommand("select * from `test` where id = 1")->queryOne();
    PDO::createCommand("select * from `test` where id = 2")->queryOne();
    return PDO::createCommand("select * from `test` limit 5")->queryAll();
}
測(cè)試結(jié)果

常駐內(nèi)存模式(同步):

進(jìn)程數(shù) 并發(fā)數(shù) RPS
8 100 838.65
8 300 683.78
8 500 688.56
50 100 770.69
50 300 304.90
50 300 378.95

協(xié)程模式:

進(jìn)程數(shù) 并發(fā)數(shù) RPS
8 100 834.12
8 300 837.50
8 500 824.14

協(xié)程在本次測(cè)試中并沒(méi)有像之前的傳統(tǒng) Apache/FPM 模式與常駐內(nèi)存模式(同步)的測(cè)試一樣展現(xiàn)出巨大的性能提升,說(shuō)明:

在少量能快速響應(yīng)的 SQL 請(qǐng)求中,協(xié)程的提升并不明顯,應(yīng)該要在響應(yīng)時(shí)間更大時(shí),才能感受到協(xié)程優(yōu)勢(shì)。

常駐內(nèi)存模式的進(jìn)程數(shù)配置過(guò)多,并發(fā)性能反而會(huì)降低,該問(wèn)題同樣適用于傳統(tǒng) Apache/FPM 模式。

常駐內(nèi)存模式(同步)詳細(xì)測(cè)試

首先 8 個(gè) Worker 進(jìn)程,并發(fā) 100 測(cè)試,RPS 為 838.65。

C:UsersEDZ>ab -n 10000 -c 100 http://www.a.com/
This is ApacheBench, Version 2.3 <$Revision: 1757674 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking www.a.com (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software:        nginx/1.13.9
Server Hostname:        www.a.com
Server Port:            80

Document Path:          /
Document Length:        101 bytes

Concurrency Level:      100
Time taken for tests:   11.924 seconds
Complete requests:      10000
Failed requests:        0
Total transferred:      2660000 bytes
HTML transferred:       1010000 bytes
Requests per second:    838.65 [#/sec] (mean)
Time per request:       119.239 [ms] (mean)
Time per request:       1.192 [ms] (mean, across all concurrent requests)
Transfer rate:          217.85 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.2      0       4
Processing:    20  118  18.3    118     195
Waiting:       19  118  18.4    118     195
Total:         20  118  18.4    119     195

Percentage of the requests served within a certain time (ms)
  50%    119
  66%    126
  75%    130
  80%    133
  90%    141
  95%    147
  98%    155
  99%    161
 100%    195 (longest request)

然后使用 8 個(gè) Worker 進(jìn)程,并發(fā) 300 測(cè)試,RPS 為 683.78。

C:UsersEDZ>ab -n 10000 -c 300 http://www.a.com/
This is ApacheBench, Version 2.3 <$Revision: 1757674 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking www.a.com (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software:        nginx/1.13.9
Server Hostname:        www.a.com
Server Port:            80

Document Path:          /
Document Length:        101 bytes

Concurrency Level:      300
Time taken for tests:   14.624 seconds
Complete requests:      10000
Failed requests:        0
Total transferred:      2660000 bytes
HTML transferred:       1010000 bytes
Requests per second:    683.78 [#/sec] (mean)
Time per request:       438.735 [ms] (mean)
Time per request:       1.462 [ms] (mean, across all concurrent requests)
Transfer rate:          177.62 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0  30.0      0    3000
Processing:    62  432 493.4    354    3457
Waiting:       54  431 488.1    354    3455
Total:         62  433 494.1    354    3457

Percentage of the requests served within a certain time (ms)
  50%    354
  66%    373
  75%    385
  80%    392
  90%    411
  95%    432
  98%   3170
  99%   3266
 100%   3457 (longest request)

然后使用 8 個(gè) Worker 進(jìn)程,并發(fā) 500 測(cè)試,RPS 為 688.56。

C:UsersEDZ>ab -n 10000 -c 500 http://www.a.com/
This is ApacheBench, Version 2.3 <$Revision: 1757674 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking www.a.com (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software:        nginx/1.13.9
Server Hostname:        www.a.com
Server Port:            80

Document Path:          /
Document Length:        101 bytes

Concurrency Level:      500
Time taken for tests:   14.523 seconds
Complete requests:      10000
Failed requests:        0
Total transferred:      2660000 bytes
HTML transferred:       1010000 bytes
Requests per second:    688.56 [#/sec] (mean)
Time per request:       726.150 [ms] (mean)
Time per request:       1.452 [ms] (mean, across all concurrent requests)
Transfer rate:          178.87 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0  30.0      0    3000
Processing:   102  707 618.4    596    3632
Waiting:       89  703 605.6    595    3629
Total:        102  707 618.9    596    3633

Percentage of the requests served within a certain time (ms)
  50%    596
  66%    620
  75%    635
  80%    645
  90%    679
  95%   3125
  98%   3401
  99%   3495
 100%   3633 (longest request)

現(xiàn)在調(diào)整為 50 進(jìn)程,100 并發(fā)測(cè)試,RPS 為 770.69。
進(jìn)程的增加并沒(méi)有帶來(lái)并發(fā)量的提升。

C:UsersEDZ>ab -n 10000 -c 100 http://www.a.com/
This is ApacheBench, Version 2.3 <$Revision: 1757674 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking www.a.com (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software:        nginx/1.13.9
Server Hostname:        www.a.com
Server Port:            80

Document Path:          /
Document Length:        101 bytes

Concurrency Level:      100
Time taken for tests:   12.975 seconds
Complete requests:      10000
Failed requests:        0
Total transferred:      2660000 bytes
HTML transferred:       1010000 bytes
Requests per second:    770.69 [#/sec] (mean)
Time per request:       129.754 [ms] (mean)
Time per request:       1.298 [ms] (mean, across all concurrent requests)
Transfer rate:          200.20 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1  42.4      0    3000
Processing:    10  128 499.8     56    7137
Waiting:       10  127 495.8     55    7137
Total:         11  129 503.3     56    7137

Percentage of the requests served within a certain time (ms)
  50%     56
  66%     72
  75%     86
  80%     97
  90%    133
  95%    179
  98%    312
  99%   3052
 100%   7137 (longest request)

50 進(jìn)程,300 并發(fā)測(cè)試,RPS 為 304.90。
對(duì)比 8 個(gè)進(jìn)程時(shí)的結(jié)果,并發(fā)量降低非常明顯,看來(lái)進(jìn)程數(shù)過(guò)多并不能提升性能,反而會(huì)降低性能。

C:UsersEDZ>ab -n 10000 -c 300 http://www.a.com/
This is ApacheBench, Version 2.3 <$Revision: 1757674 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking www.a.com (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software:        nginx/1.13.9
Server Hostname:        www.a.com
Server Port:            80

Document Path:          /
Document Length:        101 bytes

Concurrency Level:      300
Time taken for tests:   32.798 seconds
Complete requests:      10000
Failed requests:        0
Total transferred:      2660000 bytes
HTML transferred:       1010000 bytes
Requests per second:    304.90 [#/sec] (mean)
Time per request:       983.942 [ms] (mean)
Time per request:       3.280 [ms] (mean, across all concurrent requests)
Transfer rate:          79.20 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    3  90.0      0    3001
Processing:    25  976 1339.8    189    3694
Waiting:       23  954 1316.5    188    3691
Total:         25  979 1341.0    189    3694

Percentage of the requests served within a certain time (ms)
  50%    189
  66%    289
  75%   3094
  80%   3113
  90%   3184
  95%   3249
  98%   3315
  99%   3375
 100%   3694 (longest request)

50 進(jìn)程,500 并發(fā)測(cè)試,RPS 為 378.95。

C:UsersEDZ>ab -n 10000 -c 500 http://www.a.com/
This is ApacheBench, Version 2.3 <$Revision: 1757674 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking www.a.com (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software:        nginx/1.13.9
Server Hostname:        www.a.com
Server Port:            80

Document Path:          /
Document Length:        101 bytes

Concurrency Level:      500
Time taken for tests:   26.389 seconds
Complete requests:      10000
Failed requests:        0
Total transferred:      2660000 bytes
HTML transferred:       1010000 bytes
Requests per second:    378.95 [#/sec] (mean)
Time per request:       1319.431 [ms] (mean)
Time per request:       2.639 [ms] (mean, across all concurrent requests)
Transfer rate:          98.44 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    2  79.4      0    3001
Processing:    64 1306 1434.7    341    3962
Waiting:       17 1224 1391.4    321    3959
Total:         65 1308 1435.2    342    3963

Percentage of the requests served within a certain time (ms)
  50%    342
  66%   3142
  75%   3168
  80%   3195
  90%   3292
  95%   3374
  98%   3467
  99%   3516
 100%   3963 (longest request)
協(xié)程模式詳細(xì)測(cè)試

首先 8 個(gè) Worker 進(jìn)程,并發(fā) 100 測(cè)試,RPS 為 834.12。

C:UsersEDZ>ab -n 10000 -c 100 http://www.a.com/
This is ApacheBench, Version 2.3 <$Revision: 1757674 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking www.a.com (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software:        nginx/1.13.9
Server Hostname:        www.a.com
Server Port:            80

Document Path:          /
Document Length:        101 bytes

Concurrency Level:      100
Time taken for tests:   11.989 seconds
Complete requests:      10000
Failed requests:        0
Total transferred:      2660000 bytes
HTML transferred:       1010000 bytes
Requests per second:    834.12 [#/sec] (mean)
Time per request:       119.886 [ms] (mean)
Time per request:       1.199 [ms] (mean, across all concurrent requests)
Transfer rate:          216.68 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.3      0       4
Processing:    84  119   9.8    122     165
Waiting:       84  119   9.8    122     164
Total:         84  119   9.8    123     165

Percentage of the requests served within a certain time (ms)
  50%    123
  66%    124
  75%    125
  80%    125
  90%    126
  95%    128
  98%    131
  99%    137
 100%    165 (longest request)

然后使用 8 個(gè) Worker 進(jìn)程,并發(fā) 300 測(cè)試,RPS 為 837.50。

C:UsersEDZ>ab -n 10000 -c 300 http://www.a.com/
This is ApacheBench, Version 2.3 <$Revision: 1757674 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking www.a.com (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software:        nginx/1.13.9
Server Hostname:        www.a.com
Server Port:            80

Document Path:          /
Document Length:        101 bytes

Concurrency Level:      300
Time taken for tests:   11.940 seconds
Complete requests:      10000
Failed requests:        0
Total transferred:      2660000 bytes
HTML transferred:       1010000 bytes
Requests per second:    837.50 [#/sec] (mean)
Time per request:       358.207 [ms] (mean)
Time per request:       1.194 [ms] (mean, across all concurrent requests)
Transfer rate:          217.55 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1  42.4      0    3001
Processing:    86  354 1043.0    161    7172
Waiting:       86  344 1011.9    160    7172
Total:         86  355 1044.5    161    7172

Percentage of the requests served within a certain time (ms)
  50%    161
  66%    182
  75%    199
  80%    212
  90%    251
  95%    302
  98%   6103
  99%   6135
 100%   7172 (longest request)

然后使用 8 個(gè) Worker 進(jìn)程,并發(fā) 500 測(cè)試,RPS 為 824.14。

C:UsersEDZ>ab -n 10000 -c 500 http://www.a.com/
This is ApacheBench, Version 2.3 <$Revision: 1757674 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking www.a.com (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software:        nginx/1.13.9
Server Hostname:        www.a.com
Server Port:            80

Document Path:          /
Document Length:        101 bytes

Concurrency Level:      500
Time taken for tests:   12.134 seconds
Complete requests:      10000
Failed requests:        0
Total transferred:      2660000 bytes
HTML transferred:       1010000 bytes
Requests per second:    824.14 [#/sec] (mean)
Time per request:       606.690 [ms] (mean)
Time per request:       1.213 [ms] (mean, across all concurrent requests)
Transfer rate:          214.08 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.3      0       4
Processing:    92  332 585.3    198    6931
Waiting:       91  331 585.5    196    6931
Total:         92  332 585.3    198    6931

Percentage of the requests served within a certain time (ms)
  50%    198
  66%    242
  75%    284
  80%    334
  90%    587
  95%    932
  98%   1216
  99%   2390
 100%   6931 (longest request)
MixPHP

GitHub: https://github.com/mixstart/m...
官網(wǎng):http://www.mixphp.cn/

文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請(qǐng)注明本文地址:http://systransis.cn/yun/30871.html

相關(guān)文章

  • Swoole4.x之協(xié)程變量訪問(wèn)安全協(xié)程連接池實(shí)現(xiàn)

    摘要:訪問(wèn)安全問(wèn)題為什么說(shuō)有訪問(wèn)安全問(wèn)題呢傳統(tǒng)地,在的的環(huán)境中,很少有遇到所謂變量安全訪問(wèn)問(wèn)題。上下文管理器為了解決這個(gè)問(wèn)題,我們引入?yún)f(xié)程上下文管理這樣的概念,由此來(lái)實(shí)現(xiàn)每個(gè)協(xié)程環(huán)境內(nèi)的數(shù)據(jù)隔離。 訪問(wèn)安全問(wèn)題 為什么說(shuō)有訪問(wèn)安全問(wèn)題呢?傳統(tǒng)地,在php的的環(huán)境中,很少有Phper遇到所謂變量安全訪問(wèn)問(wèn)題。舉個(gè)例子,代碼大約如下: class db { protected stati...

    aisuhua 評(píng)論0 收藏0
  • 【宇潤(rùn)日常瘋測(cè)-007】Swoole 協(xié)程與傳統(tǒng) fpm 同步模式比較

    摘要:初識(shí)協(xié)程執(zhí)行結(jié)果協(xié)程與同步模式比較我們一直在說(shuō)協(xié)程適合用于密集場(chǎng)景,在同樣的硬件配置環(huán)境下,它會(huì)比傳統(tǒng)的同步模式承載更多的訪問(wèn)量。假設(shè)一次查詢(xún)?yōu)?,在傳統(tǒng)同步模式下,當(dāng)前進(jìn)程在這的時(shí)間里,是不能做其它操作的。同步模式,耗費(fèi)左右的是。 如果說(shuō)數(shù)組是 PHP 的精髓,數(shù)組玩得不6的,根本不能算是會(huì)用PHP。那協(xié)程對(duì)于 Swoole 也是同理,不理解協(xié)程去用 Swoole,那就是在瞎用。 首先...

    henry14 評(píng)論0 收藏0
  • 聊聊 2018 年后端技術(shù)趨勢(shì)

    摘要:現(xiàn)在在后端業(yè)務(wù)開(kāi)發(fā)編程方面,技術(shù)力量強(qiáng)的團(tuán)隊(duì)已經(jīng)開(kāi)始將技術(shù)棧從同步模式切換為異步了。使用這些技術(shù)方案是無(wú)法兼容已有程序的。影響了異步回調(diào)技術(shù)棧的普及。將會(huì)成為未來(lái)后端開(kāi)發(fā)領(lǐng)域的主流技術(shù)方案。 今天太忙,少寫(xiě)一點(diǎn),后面再補(bǔ)充。 異步模式 Go 語(yǔ)言越來(lái)越熱門(mén),很多大型互聯(lián)網(wǎng)公司后端正在轉(zhuǎn)向 GO 。Java 圈知名的服務(wù)化框架 Dubbo 也宣布轉(zhuǎn)型異步模式。這是一個(gè)大趨勢(shì),異步模式已經(jīng)...

    Miyang 評(píng)論0 收藏0
  • PHP物聯(lián)網(wǎng)開(kāi)發(fā)利器之Actor并發(fā)模型

    摘要:然而盡管如此,很多人可能都沒(méi)有思考過(guò),如何優(yōu)雅的寫(xiě)出自己的物聯(lián)網(wǎng)服務(wù)器。 PHP不適合做物聯(lián)網(wǎng)服務(wù)端嗎? 在傳統(tǒng)的思維中,經(jīng)常會(huì)有人告訴你,php不適合用來(lái)做物聯(lián)網(wǎng)服務(wù)端,讓你換java,node,go等其他語(yǔ)言,是的,沒(méi)錯(cuò)傳統(tǒng)意義上的php,確實(shí)很難做物聯(lián)網(wǎng)服務(wù)器,因?yàn)樗鼘?shí)在太蹩腳了,當(dāng)然,這也不是意味著徹底就不能做。舉個(gè)例子,當(dāng)你想實(shí)現(xiàn)一個(gè)TCP服務(wù)器的時(shí)候,你可能需要寫(xiě)出原理大約...

    ixlei 評(píng)論0 收藏0
  • PyTips 0x 12 - Python 線程協(xié)程(1)

    摘要:中關(guān)于線程的標(biāo)準(zhǔn)庫(kù)是,之前在版本中的在之后更名為,無(wú)論是還是都應(yīng)該盡量避免使用較為底層的而應(yīng)該使用。而與線程相比,協(xié)程尤其是結(jié)合事件循環(huán)無(wú)論在編程模型還是語(yǔ)法上,看起來(lái)都是非常友好的單線程同步過(guò)程。 項(xiàng)目地址:https://git.io/pytips 要說(shuō)到線程(Thread)與協(xié)程(Coroutine)似乎總是需要從并行(Parallelism)與并發(fā)(Concurrency)談起...

    el09xccxy 評(píng)論0 收藏0

發(fā)表評(píng)論

0條評(píng)論

最新活動(dòng)
閱讀需要支付1元查看
<