Recent

Author Topic: new WebServer  (Read 4570 times)

Blestan

  • Sr. Member
  • ****
  • Posts: 461
new WebServer
« on: November 05, 2015, 10:04:18 am »
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 :)
Speak postscript or die!
Translate to pdf and live!

ttomas

  • Sr. Member
  • ****
  • Posts: 251
Re: new WebServer
« Reply #1 on: November 05, 2015, 03:45:28 pm »
Happy coding, FPC need new async TCP/HTTP server something like libuv. Do you have any success with binding libuv with FPC?

Blestan

  • Sr. Member
  • ****
  • Posts: 461
Re: new WebServer
« Reply #2 on: November 05, 2015, 04:23:23 pm »
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 ...
Speak postscript or die!
Translate to pdf and live!

ttomas

  • Sr. Member
  • ****
  • Posts: 251
Re: new WebServer
« Reply #3 on: November 05, 2015, 08:17:15 pm »
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

  • Sr. Member
  • ****
  • Posts: 461
Re: new WebServer
« Reply #4 on: November 05, 2015, 09:39:44 pm »
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
Speak postscript or die!
Translate to pdf and live!

chain_reaction

  • New Member
  • *
  • Posts: 22
Re: new WebServer
« Reply #5 on: November 06, 2015, 05:17:57 am »
Good project idea and loved to hear soon, maybe the project might be compete with node.js or node.pas :D

 

TinyPortal © 2005-2018