atomic web server threads

Share your advanced PureBasic knowledge/code with the community.
User avatar
idle
Always Here
Always Here
Posts: 5834
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: atomic web server threads

Post by idle »

Thanks benbi It's not so easy to keep it simple, I could add a few 1000 lines in an instant but I'm trying to keep it closer to plain pb which I find hard to do.

I could also simplify it a lot more by by using one thread per client, but I think this way where a client can have mutiple requests going at once might be better performance than queuing and serializing. Infratec kindly sent me his multi threaded server so I can test, the difference and see which is better. Tcp is tricky to tune.
User avatar
idle
Always Here
Always Here
Posts: 5834
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: atomic web server threads

Post by idle »

After Caronte3D spun up a server in Germany and sent me the link to test, I'm happy to say it's fast enough, it only took 5 seconds to download the ~6mb test payload from NZ which is pretty good.

I've been adding shared servers, so you can run multiple sites on the same server and port. you just add a folder with the domain name under your www/ folder. Then to test just add the domains to your hosts file
127.0.0.1 atomicwebserver.com
127.0.0.1 atomicwebserver3.com
but while this uses the host: field so set the directory it adds a risk of escaping the root directory
for now I've tested for ".." in the *request\host string to avert it but I'm not sure if that's good enough?

There's still a bit to do before it's ready.
User avatar
Caronte3D
Addict
Addict
Posts: 1355
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Re: atomic web server threads

Post by Caronte3D »

Glad to help :D
Do you think SSL would be doable for atomic server, without all the inherent complexity?
User avatar
idle
Always Here
Always Here
Posts: 5834
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: atomic web server threads

Post by idle »

Caronte3D wrote: Mon Apr 08, 2024 8:49 am Glad to help :D
Do you think SSL would be doable for atomic server, without all the inherent complexity?
Yes absolutely, it's not that hard to do for windows or Linux but I don't know about mac OS or arm builds.
I'm still working through how to present the adaptation to support shared servers which is something I need, however it complicates things a bit from the users perspective and it also has an impact on how to do TLS for shared servers. So once I've got that sorted I can look to adding it.
User avatar
Caronte3D
Addict
Addict
Posts: 1355
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Re: atomic web server threads

Post by Caronte3D »

Go, go, go! 8)
Image
User avatar
idle
Always Here
Always Here
Posts: 5834
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: atomic web server threads

Post by idle »

In the case of a shared application server I'm still looking into how to do it as a dll plug-in, that way you can recompile your app without shutting the server down or recompiling it. By dynamicly loading and unloading your application dll. your dll hosts the urihandlers and runtime procedures required by your application to process the info.

Once I've got that ironed out I can look at doing SSL.
User avatar
Caronte3D
Addict
Addict
Posts: 1355
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Re: atomic web server threads

Post by Caronte3D »

It seems like a good idea to use a DLL :wink:
User avatar
idle
Always Here
Always Here
Posts: 5834
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: atomic web server threads

Post by idle »

I decided to build in a reverse proxy, which is a much better solution overall as you can totally isolate the servers and then they don't need to be on the same instance, machine or network.
it seems to be working fine on the same instance and also as separate instances . :D
Though it's it's still not 100% and it doesn't work so well across the Lan?

The short of it is you can run multiple servers on different ports and interfaces and still access them through the proxy

to make atomicwebserver1.com, proxy calls to atomicwebserver2.com

Code: Select all

server1 = Atomic_Server_Init("atomicwebserver1.com","www/","192.168.1.10","atomicwebserver1.com",80,#PB_Network_IPv4,5000,@CBPost(),@CBGet())
Atomic_Server_Add_Proxy(server1,"atomicwebserver2.com","127.0.0.1",81) 
and server 2

Code: Select all

server2 = Atomic_Server_Init("atomicwebserver2.com","www/","127.0.0.1","atomicwebserver2.com",81,#PB_Network_IPv4,5000,@CBPost(),@CBGet())
still a bit of debugging to do before its ready
User avatar
skinkairewalker
Enthusiast
Enthusiast
Posts: 772
Joined: Fri Dec 04, 2015 9:26 pm

Re: atomic web server threads

Post by skinkairewalker »

This is brilliant, excellent work.
User avatar
idle
Always Here
Always Here
Posts: 5834
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: atomic web server threads

Post by idle »

skinkairewalker wrote: Thu Apr 11, 2024 9:09 pm This is brilliant, excellent work.
It should be ready to post next week, I'm still debugging the reverse proxy and I also need to finish off the use case examples and edit the test site contents.
User avatar
idle
Always Here
Always Here
Posts: 5834
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: atomic web server threads

Post by idle »

a somewhat slow test site to US and Europe atomicwebserver.com
I will put on a cloud VM at some point as it's just to slow from the island
jamirokwai
Enthusiast
Enthusiast
Posts: 796
Joined: Tue May 20, 2008 2:12 am
Location: Cologne, Germany
Contact:

Re: atomic web server threads

Post by jamirokwai »

Hi Idle,

great work! For a few years now, I am looking for a decent way to remove electron and other blown up solutions for local webpages from my workflow. This seems to be it! Thanks for the work. Really looking forward for things like SSL and GZIP!

I tried to download the code via "Get Code" from the page, it always stopped after a few kbs. Maybe, Germany is too far away from NZ...
Regards,
JamiroKwai
User avatar
idle
Always Here
Always Here
Posts: 5834
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: atomic web server threads

Post by idle »

jamirokwai wrote: Sun Apr 14, 2024 6:19 pm Hi Idle,

great work! For a few years now, I am looking for a decent way to remove electron and other blown up solutions for local webpages from my workflow. This seems to be it! Thanks for the work. Really looking forward for things like SSL and GZIP!

I tried to download the code via "Get Code" from the page, it always stopped after a few kbs. Maybe, Germany is too far away from NZ...
I'll put the code on github today.
it'll be easy enough to add support for deflate and gzip
User avatar
idle
Always Here
Always Here
Posts: 5834
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: atomic web server threads

Post by idle »

Added to github with test site.
https://github.com/idle-PB/atomic_webserver_3
PBJim
Enthusiast
Enthusiast
Posts: 294
Joined: Fri Jan 19, 2024 11:56 pm

Re: atomic web server threads

Post by PBJim »

Thanks very much Idle, there is the below code which won't compile, as it's attemping to put -1 into an unsigned .a

Code: Select all

  Structure ST
    a.a[256] 
  EndStructure  
  Static skiptable.ST 

[...]
    For i = 0 To 255
      Skiptable\a[i] = -1;
Line 520: Overflow error a 'ascii' (.a) value must be between 0 and 255
Post Reply