-
Notifications
You must be signed in to change notification settings - Fork 53
Performance test: read & write vs recv & send
Determine the better perfoming socket reading/writing methods: read/write or recv/send.
Machine: AWS EC2 t2.micro (1 vCPU ‒ Intel Xeon, 1 GB RAM), Amazon Linux AMI 2018.03
Silgy version: 4.0.1
There were two Silgy apps:
- Server: Silgy Hello World as it was, and with tweaked engine version (with recv/send instead of read/write), started by
ec2-user
- Client: perf with 10
silgy_svc
processes, started byroot
There were 4 tests, every time with freshly started server:
-
read/write version queried by 10 simultaneous batches @ 100 requests each, 3 series
-
recv/send version queried by 10 simultaneous batches @ 100 requests each, 3 series
-
read/write version queried by 10 simultaneous batches @ 200 requests each, 3 series
-
recv/send version queried by 10 simultaneous batches @ 200 requests each, 3 series
The results, grouped by the methods sets:
-
read/write
-------------------------------------------------- Memory: 4 880 kB (4.77 MB / 0.00 GB) -------------------------------------------------- req: 3000 average: 0.041 ms connections HWM: 10 -------------------------------------------------- Memory: 5 048 kB (4.93 MB / 0.00 GB) -------------------------------------------------- req: 6000 average: 0.037 ms connections HWM: 10
-
recv/send
-------------------------------------------------- Memory: 4 788 kB (4.68 MB / 0.00 GB) -------------------------------------------------- req: 3000 average: 0.032 ms connections HWM: 10 -------------------------------------------------- Memory: 4 788 kB (4.68 MB / 0.00 GB) -------------------------------------------------- req: 6000 average: 0.039 ms connections HWM: 10
Although there was no clear performance winner, with both versions hovering around 37 μs (actually combined averages are 39 and 35.5 μs), yet there is clear difference in memory usage in favour of recv/send. This set is also more portable, as for example read/write can't be used for sockets on Windows.