资讯专栏INFORMATION COLUMN

Swoole 同步模式与协程模式的对比

WilsonLiu95 / 1098人阅读

摘要:开始测试是一个基于的常驻内存协程三模高性能框架,由于该框架同时具备常驻内存模式协程模式,所以能很方便的测试结果。常驻内存模式的进程数配置过多,并发性能反而会降低,该问题同样适用于传统模式。

在现代化 PHP 高级开发中,Swoole 为 PHP 带来了更多可能,如:常驻内存、协程,关于传统的 Apache/FPM 模式与常驻内存模式(同步)的巨大差异,之前我做过测试,大家能直观的感受到性能的巨大提升,但是协程到来后,又带来了多少性能的提升呢?提升的又是哪方面的性能?下面逐步测试一下。

传统的 Apache/FPM 模式与常驻内存模式(同步)的测试文章:
MixPHP 并发性能全面对比测试

协程的优势

协程模式与常驻内存模式(同步)/传统模式相比:

常驻模式/传统模式都属于同步阻塞编程,由于同一个进程不能并行处理请求,所以为了提高并发,只能开启更多的进程,通常超过 100 甚至更多,每个进程都有基础的内存消耗,加起来就很多了,而且受限于 Linux 总进程数限制,并发总数无法突破,加上进程非常多之后,CPU 需要更多的线程切换,浪费了很多性能,当然相比 FPM 的传统模式每次都需从头开始,常驻模式还是要好非常多的,但是协程显然更加优秀。

协程模式的执行方式:

协程模式中一个进程可以同时执行 N 个请求,但同一时刻只执行其中的某一个请求,也就是说,当执行到 MySQL/Redis 这些客户端时,由于需要等待客户端响应,常驻模式/传统模式通常是在傻傻的等待响应,而协程这个时候会挂起当前协程,切换到其他协程中去处理其他请求,所以协程能同时处理 N 个请求,每增加一个请求只需增加一些内存消耗,相比增加一个进程的内存消耗,显然是少太多的,由于协程能并行处理,所以通常只需配置于 CPU 数量 1~2 倍左右的进程数即可,更少的进程带来更少的 CPU 线程切换,又减少很多性能损耗。

开始测试

MixPHP 是一个基于 Swoole 的FPM、常驻内存、协程三模 PHP 高性能框架,由于该框架同时具备常驻内存模式、协程模式,所以能很方便的测试结果。

测试环境:

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

其他参数如下:

</>复制代码

  1. Server Name: mix-httpd
  2. Framework Version: 1.1.0-RC
  3. PHP Version: 7.2.9
  4. Swoole Version: 4.1.0
  5. Listen Addr: 127.0.0.1
  6. Listen Port: 9501

代码:

模拟常用的 HTTP 开发需求,执行三个 SQL 请求。

</>复制代码

  1. // 默认动作
  2. public function actionIndex()
  3. {
  4. PDO::createCommand("select * from `test` where id = 1")->queryOne();
  5. PDO::createCommand("select * from `test` where id = 2")->queryOne();
  6. return PDO::createCommand("select * from `test` limit 5")->queryAll();
  7. }
测试结果

常驻内存模式(同步):

进程数 并发数 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

协程模式:

进程数 并发数 RPS
8 100 834.12
8 300 837.50
8 500 824.14

协程在本次测试中并没有像之前的传统 Apache/FPM 模式与常驻内存模式(同步)的测试一样展现出巨大的性能提升,说明:

在少量能快速响应的 SQL 请求中,协程的提升并不明显,应该要在响应时间更大时,才能感受到协程优势。

常驻内存模式的进程数配置过多,并发性能反而会降低,该问题同样适用于传统 Apache/FPM 模式。

常驻内存模式(同步)详细测试

首先 8 个 Worker 进程,并发 100 测试,RPS 为 838.65。

</>复制代码

  1. C:UsersEDZ>ab -n 10000 -c 100 http://www.a.com/
  2. This is ApacheBench, Version 2.3 <$Revision: 1757674 $>
  3. Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
  4. Licensed to The Apache Software Foundation, http://www.apache.org/
  5. Benchmarking www.a.com (be patient)
  6. Completed 1000 requests
  7. Completed 2000 requests
  8. Completed 3000 requests
  9. Completed 4000 requests
  10. Completed 5000 requests
  11. Completed 6000 requests
  12. Completed 7000 requests
  13. Completed 8000 requests
  14. Completed 9000 requests
  15. Completed 10000 requests
  16. Finished 10000 requests
  17. Server Software: nginx/1.13.9
  18. Server Hostname: www.a.com
  19. Server Port: 80
  20. Document Path: /
  21. Document Length: 101 bytes
  22. Concurrency Level: 100
  23. Time taken for tests: 11.924 seconds
  24. Complete requests: 10000
  25. Failed requests: 0
  26. Total transferred: 2660000 bytes
  27. HTML transferred: 1010000 bytes
  28. Requests per second: 838.65 [#/sec] (mean)
  29. Time per request: 119.239 [ms] (mean)
  30. Time per request: 1.192 [ms] (mean, across all concurrent requests)
  31. Transfer rate: 217.85 [Kbytes/sec] received
  32. Connection Times (ms)
  33. min mean[+/-sd] median max
  34. Connect: 0 0 0.2 0 4
  35. Processing: 20 118 18.3 118 195
  36. Waiting: 19 118 18.4 118 195
  37. Total: 20 118 18.4 119 195
  38. Percentage of the requests served within a certain time (ms)
  39. 50% 119
  40. 66% 126
  41. 75% 130
  42. 80% 133
  43. 90% 141
  44. 95% 147
  45. 98% 155
  46. 99% 161
  47. 100% 195 (longest request)

然后使用 8 个 Worker 进程,并发 300 测试,RPS 为 683.78。

</>复制代码

  1. C:UsersEDZ>ab -n 10000 -c 300 http://www.a.com/
  2. This is ApacheBench, Version 2.3 <$Revision: 1757674 $>
  3. Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
  4. Licensed to The Apache Software Foundation, http://www.apache.org/
  5. Benchmarking www.a.com (be patient)
  6. Completed 1000 requests
  7. Completed 2000 requests
  8. Completed 3000 requests
  9. Completed 4000 requests
  10. Completed 5000 requests
  11. Completed 6000 requests
  12. Completed 7000 requests
  13. Completed 8000 requests
  14. Completed 9000 requests
  15. Completed 10000 requests
  16. Finished 10000 requests
  17. Server Software: nginx/1.13.9
  18. Server Hostname: www.a.com
  19. Server Port: 80
  20. Document Path: /
  21. Document Length: 101 bytes
  22. Concurrency Level: 300
  23. Time taken for tests: 14.624 seconds
  24. Complete requests: 10000
  25. Failed requests: 0
  26. Total transferred: 2660000 bytes
  27. HTML transferred: 1010000 bytes
  28. Requests per second: 683.78 [#/sec] (mean)
  29. Time per request: 438.735 [ms] (mean)
  30. Time per request: 1.462 [ms] (mean, across all concurrent requests)
  31. Transfer rate: 177.62 [Kbytes/sec] received
  32. Connection Times (ms)
  33. min mean[+/-sd] median max
  34. Connect: 0 0 30.0 0 3000
  35. Processing: 62 432 493.4 354 3457
  36. Waiting: 54 431 488.1 354 3455
  37. Total: 62 433 494.1 354 3457
  38. Percentage of the requests served within a certain time (ms)
  39. 50% 354
  40. 66% 373
  41. 75% 385
  42. 80% 392
  43. 90% 411
  44. 95% 432
  45. 98% 3170
  46. 99% 3266
  47. 100% 3457 (longest request)

然后使用 8 个 Worker 进程,并发 500 测试,RPS 为 688.56。

</>复制代码

  1. C:UsersEDZ>ab -n 10000 -c 500 http://www.a.com/
  2. This is ApacheBench, Version 2.3 <$Revision: 1757674 $>
  3. Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
  4. Licensed to The Apache Software Foundation, http://www.apache.org/
  5. Benchmarking www.a.com (be patient)
  6. Completed 1000 requests
  7. Completed 2000 requests
  8. Completed 3000 requests
  9. Completed 4000 requests
  10. Completed 5000 requests
  11. Completed 6000 requests
  12. Completed 7000 requests
  13. Completed 8000 requests
  14. Completed 9000 requests
  15. Completed 10000 requests
  16. Finished 10000 requests
  17. Server Software: nginx/1.13.9
  18. Server Hostname: www.a.com
  19. Server Port: 80
  20. Document Path: /
  21. Document Length: 101 bytes
  22. Concurrency Level: 500
  23. Time taken for tests: 14.523 seconds
  24. Complete requests: 10000
  25. Failed requests: 0
  26. Total transferred: 2660000 bytes
  27. HTML transferred: 1010000 bytes
  28. Requests per second: 688.56 [#/sec] (mean)
  29. Time per request: 726.150 [ms] (mean)
  30. Time per request: 1.452 [ms] (mean, across all concurrent requests)
  31. Transfer rate: 178.87 [Kbytes/sec] received
  32. Connection Times (ms)
  33. min mean[+/-sd] median max
  34. Connect: 0 0 30.0 0 3000
  35. Processing: 102 707 618.4 596 3632
  36. Waiting: 89 703 605.6 595 3629
  37. Total: 102 707 618.9 596 3633
  38. Percentage of the requests served within a certain time (ms)
  39. 50% 596
  40. 66% 620
  41. 75% 635
  42. 80% 645
  43. 90% 679
  44. 95% 3125
  45. 98% 3401
  46. 99% 3495
  47. 100% 3633 (longest request)

现在调整为 50 进程,100 并发测试,RPS 为 770.69。
进程的增加并没有带来并发量的提升。

</>复制代码

  1. C:UsersEDZ>ab -n 10000 -c 100 http://www.a.com/
  2. This is ApacheBench, Version 2.3 <$Revision: 1757674 $>
  3. Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
  4. Licensed to The Apache Software Foundation, http://www.apache.org/
  5. Benchmarking www.a.com (be patient)
  6. Completed 1000 requests
  7. Completed 2000 requests
  8. Completed 3000 requests
  9. Completed 4000 requests
  10. Completed 5000 requests
  11. Completed 6000 requests
  12. Completed 7000 requests
  13. Completed 8000 requests
  14. Completed 9000 requests
  15. Completed 10000 requests
  16. Finished 10000 requests
  17. Server Software: nginx/1.13.9
  18. Server Hostname: www.a.com
  19. Server Port: 80
  20. Document Path: /
  21. Document Length: 101 bytes
  22. Concurrency Level: 100
  23. Time taken for tests: 12.975 seconds
  24. Complete requests: 10000
  25. Failed requests: 0
  26. Total transferred: 2660000 bytes
  27. HTML transferred: 1010000 bytes
  28. Requests per second: 770.69 [#/sec] (mean)
  29. Time per request: 129.754 [ms] (mean)
  30. Time per request: 1.298 [ms] (mean, across all concurrent requests)
  31. Transfer rate: 200.20 [Kbytes/sec] received
  32. Connection Times (ms)
  33. min mean[+/-sd] median max
  34. Connect: 0 1 42.4 0 3000
  35. Processing: 10 128 499.8 56 7137
  36. Waiting: 10 127 495.8 55 7137
  37. Total: 11 129 503.3 56 7137
  38. Percentage of the requests served within a certain time (ms)
  39. 50% 56
  40. 66% 72
  41. 75% 86
  42. 80% 97
  43. 90% 133
  44. 95% 179
  45. 98% 312
  46. 99% 3052
  47. 100% 7137 (longest request)

50 进程,300 并发测试,RPS 为 304.90。
对比 8 个进程时的结果,并发量降低非常明显,看来进程数过多并不能提升性能,反而会降低性能。

</>复制代码

  1. C:UsersEDZ>ab -n 10000 -c 300 http://www.a.com/
  2. This is ApacheBench, Version 2.3 <$Revision: 1757674 $>
  3. Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
  4. Licensed to The Apache Software Foundation, http://www.apache.org/
  5. Benchmarking www.a.com (be patient)
  6. Completed 1000 requests
  7. Completed 2000 requests
  8. Completed 3000 requests
  9. Completed 4000 requests
  10. Completed 5000 requests
  11. Completed 6000 requests
  12. Completed 7000 requests
  13. Completed 8000 requests
  14. Completed 9000 requests
  15. Completed 10000 requests
  16. Finished 10000 requests
  17. Server Software: nginx/1.13.9
  18. Server Hostname: www.a.com
  19. Server Port: 80
  20. Document Path: /
  21. Document Length: 101 bytes
  22. Concurrency Level: 300
  23. Time taken for tests: 32.798 seconds
  24. Complete requests: 10000
  25. Failed requests: 0
  26. Total transferred: 2660000 bytes
  27. HTML transferred: 1010000 bytes
  28. Requests per second: 304.90 [#/sec] (mean)
  29. Time per request: 983.942 [ms] (mean)
  30. Time per request: 3.280 [ms] (mean, across all concurrent requests)
  31. Transfer rate: 79.20 [Kbytes/sec] received
  32. Connection Times (ms)
  33. min mean[+/-sd] median max
  34. Connect: 0 3 90.0 0 3001
  35. Processing: 25 976 1339.8 189 3694
  36. Waiting: 23 954 1316.5 188 3691
  37. Total: 25 979 1341.0 189 3694
  38. Percentage of the requests served within a certain time (ms)
  39. 50% 189
  40. 66% 289
  41. 75% 3094
  42. 80% 3113
  43. 90% 3184
  44. 95% 3249
  45. 98% 3315
  46. 99% 3375
  47. 100% 3694 (longest request)

50 进程,500 并发测试,RPS 为 378.95。

</>复制代码

  1. C:UsersEDZ>ab -n 10000 -c 500 http://www.a.com/
  2. This is ApacheBench, Version 2.3 <$Revision: 1757674 $>
  3. Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
  4. Licensed to The Apache Software Foundation, http://www.apache.org/
  5. Benchmarking www.a.com (be patient)
  6. Completed 1000 requests
  7. Completed 2000 requests
  8. Completed 3000 requests
  9. Completed 4000 requests
  10. Completed 5000 requests
  11. Completed 6000 requests
  12. Completed 7000 requests
  13. Completed 8000 requests
  14. Completed 9000 requests
  15. Completed 10000 requests
  16. Finished 10000 requests
  17. Server Software: nginx/1.13.9
  18. Server Hostname: www.a.com
  19. Server Port: 80
  20. Document Path: /
  21. Document Length: 101 bytes
  22. Concurrency Level: 500
  23. Time taken for tests: 26.389 seconds
  24. Complete requests: 10000
  25. Failed requests: 0
  26. Total transferred: 2660000 bytes
  27. HTML transferred: 1010000 bytes
  28. Requests per second: 378.95 [#/sec] (mean)
  29. Time per request: 1319.431 [ms] (mean)
  30. Time per request: 2.639 [ms] (mean, across all concurrent requests)
  31. Transfer rate: 98.44 [Kbytes/sec] received
  32. Connection Times (ms)
  33. min mean[+/-sd] median max
  34. Connect: 0 2 79.4 0 3001
  35. Processing: 64 1306 1434.7 341 3962
  36. Waiting: 17 1224 1391.4 321 3959
  37. Total: 65 1308 1435.2 342 3963
  38. Percentage of the requests served within a certain time (ms)
  39. 50% 342
  40. 66% 3142
  41. 75% 3168
  42. 80% 3195
  43. 90% 3292
  44. 95% 3374
  45. 98% 3467
  46. 99% 3516
  47. 100% 3963 (longest request)
协程模式详细测试

首先 8 个 Worker 进程,并发 100 测试,RPS 为 834.12。

</>复制代码

  1. C:UsersEDZ>ab -n 10000 -c 100 http://www.a.com/
  2. This is ApacheBench, Version 2.3 <$Revision: 1757674 $>
  3. Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
  4. Licensed to The Apache Software Foundation, http://www.apache.org/
  5. Benchmarking www.a.com (be patient)
  6. Completed 1000 requests
  7. Completed 2000 requests
  8. Completed 3000 requests
  9. Completed 4000 requests
  10. Completed 5000 requests
  11. Completed 6000 requests
  12. Completed 7000 requests
  13. Completed 8000 requests
  14. Completed 9000 requests
  15. Completed 10000 requests
  16. Finished 10000 requests
  17. Server Software: nginx/1.13.9
  18. Server Hostname: www.a.com
  19. Server Port: 80
  20. Document Path: /
  21. Document Length: 101 bytes
  22. Concurrency Level: 100
  23. Time taken for tests: 11.989 seconds
  24. Complete requests: 10000
  25. Failed requests: 0
  26. Total transferred: 2660000 bytes
  27. HTML transferred: 1010000 bytes
  28. Requests per second: 834.12 [#/sec] (mean)
  29. Time per request: 119.886 [ms] (mean)
  30. Time per request: 1.199 [ms] (mean, across all concurrent requests)
  31. Transfer rate: 216.68 [Kbytes/sec] received
  32. Connection Times (ms)
  33. min mean[+/-sd] median max
  34. Connect: 0 0 0.3 0 4
  35. Processing: 84 119 9.8 122 165
  36. Waiting: 84 119 9.8 122 164
  37. Total: 84 119 9.8 123 165
  38. Percentage of the requests served within a certain time (ms)
  39. 50% 123
  40. 66% 124
  41. 75% 125
  42. 80% 125
  43. 90% 126
  44. 95% 128
  45. 98% 131
  46. 99% 137
  47. 100% 165 (longest request)

然后使用 8 个 Worker 进程,并发 300 测试,RPS 为 837.50。

</>复制代码

  1. C:UsersEDZ>ab -n 10000 -c 300 http://www.a.com/
  2. This is ApacheBench, Version 2.3 <$Revision: 1757674 $>
  3. Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
  4. Licensed to The Apache Software Foundation, http://www.apache.org/
  5. Benchmarking www.a.com (be patient)
  6. Completed 1000 requests
  7. Completed 2000 requests
  8. Completed 3000 requests
  9. Completed 4000 requests
  10. Completed 5000 requests
  11. Completed 6000 requests
  12. Completed 7000 requests
  13. Completed 8000 requests
  14. Completed 9000 requests
  15. Completed 10000 requests
  16. Finished 10000 requests
  17. Server Software: nginx/1.13.9
  18. Server Hostname: www.a.com
  19. Server Port: 80
  20. Document Path: /
  21. Document Length: 101 bytes
  22. Concurrency Level: 300
  23. Time taken for tests: 11.940 seconds
  24. Complete requests: 10000
  25. Failed requests: 0
  26. Total transferred: 2660000 bytes
  27. HTML transferred: 1010000 bytes
  28. Requests per second: 837.50 [#/sec] (mean)
  29. Time per request: 358.207 [ms] (mean)
  30. Time per request: 1.194 [ms] (mean, across all concurrent requests)
  31. Transfer rate: 217.55 [Kbytes/sec] received
  32. Connection Times (ms)
  33. min mean[+/-sd] median max
  34. Connect: 0 1 42.4 0 3001
  35. Processing: 86 354 1043.0 161 7172
  36. Waiting: 86 344 1011.9 160 7172
  37. Total: 86 355 1044.5 161 7172
  38. Percentage of the requests served within a certain time (ms)
  39. 50% 161
  40. 66% 182
  41. 75% 199
  42. 80% 212
  43. 90% 251
  44. 95% 302
  45. 98% 6103
  46. 99% 6135
  47. 100% 7172 (longest request)

然后使用 8 个 Worker 进程,并发 500 测试,RPS 为 824.14。

</>复制代码

  1. C:UsersEDZ>ab -n 10000 -c 500 http://www.a.com/
  2. This is ApacheBench, Version 2.3 <$Revision: 1757674 $>
  3. Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
  4. Licensed to The Apache Software Foundation, http://www.apache.org/
  5. Benchmarking www.a.com (be patient)
  6. Completed 1000 requests
  7. Completed 2000 requests
  8. Completed 3000 requests
  9. Completed 4000 requests
  10. Completed 5000 requests
  11. Completed 6000 requests
  12. Completed 7000 requests
  13. Completed 8000 requests
  14. Completed 9000 requests
  15. Completed 10000 requests
  16. Finished 10000 requests
  17. Server Software: nginx/1.13.9
  18. Server Hostname: www.a.com
  19. Server Port: 80
  20. Document Path: /
  21. Document Length: 101 bytes
  22. Concurrency Level: 500
  23. Time taken for tests: 12.134 seconds
  24. Complete requests: 10000
  25. Failed requests: 0
  26. Total transferred: 2660000 bytes
  27. HTML transferred: 1010000 bytes
  28. Requests per second: 824.14 [#/sec] (mean)
  29. Time per request: 606.690 [ms] (mean)
  30. Time per request: 1.213 [ms] (mean, across all concurrent requests)
  31. Transfer rate: 214.08 [Kbytes/sec] received
  32. Connection Times (ms)
  33. min mean[+/-sd] median max
  34. Connect: 0 0 0.3 0 4
  35. Processing: 92 332 585.3 198 6931
  36. Waiting: 91 331 585.5 196 6931
  37. Total: 92 332 585.3 198 6931
  38. Percentage of the requests served within a certain time (ms)
  39. 50% 198
  40. 66% 242
  41. 75% 284
  42. 80% 334
  43. 90% 587
  44. 95% 932
  45. 98% 1216
  46. 99% 2390
  47. 100% 6931 (longest request)
MixPHP

GitHub: https://github.com/mixstart/m...
官网:http://www.mixphp.cn/

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/30871.html

相关文章

  • Swoole4.x之协程变量访问安全协程连接池实现

    摘要:访问安全问题为什么说有访问安全问题呢传统地,在的的环境中,很少有遇到所谓变量安全访问问题。上下文管理器为了解决这个问题,我们引入协程上下文管理这样的概念,由此来实现每个协程环境内的数据隔离。 访问安全问题 为什么说有访问安全问题呢?传统地,在php的的环境中,很少有Phper遇到所谓变量安全访问问题。举个例子,代码大约如下: class db { protected stati...

    aisuhua 评论0 收藏0
  • 【宇润日常疯测-007】Swoole 协程与传统 fpm 同步模式比较

    摘要:初识协程执行结果协程与同步模式比较我们一直在说协程适合用于密集场景,在同样的硬件配置环境下,它会比传统的同步模式承载更多的访问量。假设一次查询为,在传统同步模式下,当前进程在这的时间里,是不能做其它操作的。同步模式,耗费左右的是。 如果说数组是 PHP 的精髓,数组玩得不6的,根本不能算是会用PHP。那协程对于 Swoole 也是同理,不理解协程去用 Swoole,那就是在瞎用。 首先...

    henry14 评论0 收藏0
  • 聊聊 2018 年后端技术趋势

    摘要:现在在后端业务开发编程方面,技术力量强的团队已经开始将技术栈从同步模式切换为异步了。使用这些技术方案是无法兼容已有程序的。影响了异步回调技术栈的普及。将会成为未来后端开发领域的主流技术方案。 今天太忙,少写一点,后面再补充。 异步模式 Go 语言越来越热门,很多大型互联网公司后端正在转向 GO 。Java 圈知名的服务化框架 Dubbo 也宣布转型异步模式。这是一个大趋势,异步模式已经...

    Miyang 评论0 收藏0
  • PHP物联网开发利器之Actor并发模型

    摘要:然而尽管如此,很多人可能都没有思考过,如何优雅的写出自己的物联网服务器。 PHP不适合做物联网服务端吗? 在传统的思维中,经常会有人告诉你,php不适合用来做物联网服务端,让你换java,node,go等其他语言,是的,没错传统意义上的php,确实很难做物联网服务器,因为它实在太蹩脚了,当然,这也不是意味着彻底就不能做。举个例子,当你想实现一个TCP服务器的时候,你可能需要写出原理大约...

    ixlei 评论0 收藏0
  • PyTips 0x 12 - Python 线程协程(1)

    摘要:中关于线程的标准库是,之前在版本中的在之后更名为,无论是还是都应该尽量避免使用较为底层的而应该使用。而与线程相比,协程尤其是结合事件循环无论在编程模型还是语法上,看起来都是非常友好的单线程同步过程。 项目地址:https://git.io/pytips 要说到线程(Thread)与协程(Coroutine)似乎总是需要从并行(Parallelism)与并发(Concurrency)谈起...

    el09xccxy 评论0 收藏0

发表评论

0条评论

最新活动
阅读需要支付1元查看
<