1# lws minimal http server with multithreaded service 2 3Lws supports multithreaded service... build lws with `-DLWS_MAP_SMP=<max number of threads>`, the 4default is 1. If nonzero, some extra pthreads locking is built into lws and it supports multiple 5independent service threads. 6 7![lws-smp-overview](../../doc-assets/lws-smp-ov.png) 8 9When an incoming connection is accepted, it is bound to the pt with the lowest current wsi 10count, to keep the load on the threads balanced. Only the pt the wsi is bound to can service 11the thread, so although there can be as many wsi being serviced simultaneously as there are 12service threads, a wsi can only be service by the pt it is bound to. 13 14The effectiveness of the scalability depends on the load. Here is an example of roughly what can be expected 15 16![lws-smp-example](../../doc-assets/lws-smp-example.png) 17 18## build 19 20``` 21 $ cmake . && make 22``` 23 24## usage 25 26``` 27 $ ./lws-minimal-http-server-smp 28[2018/03/07 17:44:20:2409] USER: LWS minimal http server SMP | visit http://localhost:7681 29[2018/03/07 17:44:20:2410] NOTICE: Creating Vhost 'default' port 7681, 1 protocols, IPv6 on 30[2018/03/07 17:44:20:2411] NOTICE: Service threads: 10 31``` 32 33Visit http://localhost:7681 and use ab or other testing tools 34 35