You are not logged in.
Pages: 1
I have added Unix Domain Socket support into SynCrtSock. Currently in work-in-progress state, but result is very impressive (for both test nginx used as a reverse proxy):
Server listen on unix domain socket:
00:24 $ ./wrk http://localhost/timestamp
Running 10s test @ http://localhost/timestamp
2 threads and 10 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 579.69us 671.70us 16.72ms 94.57%
Req/Sec 10.16k 502.94 11.15k 81.50%
202128 requests in 10.00s, 43.75MB read
Requests/sec: 20212.22
Transfer/sec: 4.37MB
Server listen on TCP socket
00:28 $ ./wrk http://localhost/timestamp
Running 10s test @ http://localhost/timestamp
2 threads and 10 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 1.26ms 7.42ms 208.35ms 99.50%
Req/Sec 6.67k 467.95 7.57k 74.26%
133983 requests in 10.10s, 29.00MB read
Requests/sec: 13265.42
Transfer/sec: 2.87MB
Nginx upstream config
upstream myserver {
#server localhost:8881;
server unix:/home/mpv/mysoc.socket;
keepalive 32;
}
Code is inside github brunch feature/unixDomainSocket
Current state
- all server-side is work as expected. Use port "unix:/path/to/file.sock"
- TURI class understand schemas http://unix:/path/to/file.sock:/path/to/resource"
- THttpClientSocket work with cslUNIX layer
- HttpGet work with new 'unix:' schema
- THttpClientSocket work with new 'unix:' schema
TODO - TCurlHTTP should be modified (i will do it ASAP)
Any comments are welcome!
Offline
This is indeed really impressive!
Why not use httpunix:// or httpu:// or http+unix:// as TURI scheme, as proposed by https://github.com/curl/curl/issues/1338
Offline
I do not found any standard of how to represent URL for UDS
- Nginx use unix:path/to/socket for "host" but not specify how to represent a full URL (host + path)
- curl Internally use 2 parameter: one for UDS path in format /path/fo/file and one for URL in format http://localhost/url/path (bold is constant)
But we need URL schema from which we can easy separate full URL to 3 part: path to UDS, URI locator and protocol
My propose http://unix:/path/to/socket:/uri/path allow to use UDS with a minimal modification in mORMot (at last I do not modify anything in my hi-level code, just change host from "+" to "unix:/temp/my.sock" in settings)
Modification for TURI class is tiny and backward compatible.
Last edited by mpv (2018-11-05 14:20:59)
Offline
I have added Unix Domain Socket support to TCurlHTP - see #163 pull request .
Also Sample 36 is extended to test a UDS.
Can be merged to master IMHO
Offline
What a great contribution, mpv!
And for those didn't know about Unix Domain Socket:
A Unix domain socket or IPC socket (inter-process communication socket) is a data communications endpoint for exchanging data between processes executing on the same host operating system. Like named pipes, Unix domain sockets support transmission of a reliable stream of bytes (SOCK_STREAM, compare to TCP). In addition, they support ordered and reliable transmission of datagrams (SOCK_SEQPACKET, compare to SCTP), or unordered and unreliable transmission of datagrams (SOCK_DGRAM, compare to UDP). The Unix domain socket facility is a standard component of POSIX operating systems.
Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.
Offline
I have just debugged and enhanced Unix Domain Socket in mORMot 2.
Check https://github.com/synopse/mORMot2/comm … 7f4fe811f2
There was some bugs with the mormot.net.sock.posix.inc implementation (using PtrInt instead of plain integer on POSIX), and also no proper support from high-level TRestHttpServer.
Now it works well and the numbers are pretty good.
Here are some results from my just-introduced multi-thread tests (which includes UDS now):
Some Numbers taken on a Core i3 CPU with 2 Cores / 4 Threads:
- Create thread pool: 1 assertion passed 1.40ms
- TRestServerDB: 36,099 assertions passed 609.10ms
1=44533/s 2=30999/s 5=30040/s 10=30020/s 30=28552/s 50=29021/s
- TRestClientDB: 36,096 assertions passed 577.87ms
1=37165/s 2=34651/s 5=33116/s 10=31843/s 30=31150/s 50=30860/s
- TCP sockets: 36,096 assertions passed 1.20s
1=11723/s 2=14664/s 5=16084/s 10=16829/s 30=18424/s 50=18773/s
- Unix domain sockets: 36,096 assertions passed 1.12s
1=13010/s 2=14695/s 5=18749/s 10=19516/s 30=19672/s 50=20016/s
- Websockets: 36,066 assertions passed 1.93s
1=7167/s 2=9307/s 5=11994/s 10=12631/s 30=10480/s 50=8136/s
- libcurl: 36,085 assertions passed 2.73s
1=7436/s 2=9375/s 5=12693/s 10=6428/s 30=6072/s 50=5616/s
- Locked: 36,099 assertions passed 630.72ms
1=23917/s 2=33646/s 5=34147/s 10=32964/s 30=30246/s 50=28532/s
- Unlocked: 36,098 assertions passed 603.85ms
1=37165/s 2=31870/s 5=30653/s 10=30333/s 30=29932/s 50=29802/s
- Main thread: 36,091 assertions passed 617.19ms
1=27418/s 2=31227/s 5=32229/s 10=31799/s 30=30926/s 50=31010/s
- Background thread: 36,095 assertions passed 934.39ms
1=27845/s 2=27359/s 5=24503/s 10=21665/s 30=15350/s 50=13504/s
So Unix Domain Socket performance on the loopback is close to what you measured.
Each request is a POST of 98 bytes of a JSON object which makes a single INSERT to a SQlite3 DB + delayed GET of those JSON objects one by one from 1 to 50 client threads.
I wonder how the numbers would perform on a faster machine, especially with our mormot.core.fpcx64mm unit and the refactoring done with mORMot 2. My two CPU Cores are full just with one client and one server!
Offline
Pages: 1