new WebServer lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- Blestan · 2015-11-05 09:04 Hi Guys!! I'm starting a new project to write the "ultimate" webserver for fpc applications it will be based on fibers and async io. some help will be needed to make it cross platform, especially outside win/linux x86/x64 worlds on win it will be based on native fibers + IOCP + Overlaped IO. on linux - set/get context + io_submit + poll for other platforms suggestions are welcome. the main goal is to finally have a good and production state  web server to host web apps. i will create a git repo asap and share info happy coding ---------------------------------------------------------------------- ttomas · 2015-11-05 14:45 Happy coding, FPC need new async TCP/HTTP server something like libuv. Do you have any success with binding libuv with FPC? ---------------------------------------------------------------------- Blestan · 2015-11-05 15:23 hi! i already posted about libuv integrartion  in fpc ... but i think that libuv is not a solution for pascal ... the hole callback stuff is pretty hard to code and read/correct ... after several years of trials i think that fibers+async io is the way to go. fibers have advantage over callback and threads because the code logic i straight and easy to follow. there is no overhead in context switches because the swap i in user space and no need to make kernel calls. as the yield method is an procedure it self only few registers have to be saved/restored between context switches. with fibers the scheduler is pretty easy to implement and resembles very much to the libuv main loop. Also there is no need  to implement locking logic like mutex and critical sections because fibers are cooperative. a huge amount of fibers (several thousands)  can be launched without any overhead (except the memory for the stack.)  async io gives the speed needed. and extra kernel thread for the asyn io is needed just to look for the iocp (windows) or pool() unix and weak up the fibers waiting for the io. that's basiclly the idea ... ---------------------------------------------------------------------- ttomas · 2015-11-05 19:17 Fibers have one disadvantage, that is fibers cannot utilize multiprocessor machines. I really want to see some FPC server in this list https://www.techempower.com/benchmarks/ ---------------------------------------------------------------------- Blestan · 2015-11-05 20:39 yes this is a common mistake - to think that the fact that fibers cannot use multicore is disadvantage ... you can span multiple shedulers each  in thread on every core using the  "share nothing"  model and you will see that this is a clear advantage ...avoiding  complex interlocking between threads and kernel calls. the only real disadvantage of fibers is that poorly writen code will block the hole sheduler . fibers dont exclude threads ... they complete them ---------------------------------------------------------------------- chain_reaction · 2015-11-06 04:17 Good project idea and loved to hear soon, maybe the project might be compete with node.js or node.pas