State of HTTP Servers in Nim

2023-04-19 Thread alexeypetrushin
I don't know CherryPy, but yes, at the first glance, it looks similar to channels / messages based parallelism.

State of HTTP Servers in Nim

2023-04-18 Thread termer
As @ingo said, I'm thinking about having an event bus to implement the actor model. I take a lot of inspiration from Vert.x from the JVM world, which is what I use and have used in many projects successfully. There are mini-applications called Verticles in that framework which all have access t

State of HTTP Servers in Nim

2023-04-18 Thread ingo
With a bus, like [Cherrypy](https://cherrypydocrework.readthedocs.io/extend.html#server-wide-functions)? Using `asyncstream` one can bolt all kind of things together.

State of HTTP Servers in Nim

2023-04-17 Thread alexeypetrushin
It would be interesting to have a server that can share data. I don't know how, Actors like Erlang or CSP like Go or Shared Memory with Locks like Java. But there should be a way to somehow share data, otherwise there's no much use for it.

State of HTTP Servers in Nim

2023-04-16 Thread Araq
> For instance, this will copy in some cases ... It doesn't with copy arc/orc. And frankly, it's not all that hard to write fast parsers in Nim. It helps if you benchmark but if you don't, how do you end up with "fast" HTTP servers anyway?

State of HTTP Servers in Nim

2023-04-16 Thread termer
Yeah, it's a real problem. Basically anywhere I touch strings I get poor performance. Unrelated to that, but I'd like to hear your thoughts (and anyone else's), what do you think of having HTTP server context instances be thread-local for multithreading purposes? You'd need to set up a server c

State of HTTP Servers in Nim

2023-04-16 Thread pwernersbach
Makes sense. The lack of non-experimental compiler supported string views makes it really easy to write string parsing code that makes unnecessary temporary copies. For instance, this will copy in some cases: var readOnlyObject = ObjectType(readOnlyString: “foobar”) … let re

State of HTTP Servers in Nim

2023-04-16 Thread termer
I'm sure they get could a performance boost from it. When I was working on httpx, I noticed that in Valgrind it was reporting that a header parsing proc was the slowest of any. That tends to be the biggest pain point for performance in Nim, string handling. I think a lot could be done to improve

State of HTTP Servers in Nim

2023-04-16 Thread pwernersbach
The interesting thing is microasynchttpserver doesn't do anything substantial itself; it just reads the header data from an AsyncSocket, passes the header data to picohttpparser, and schedules the application callback with the data, to be completed via asyncdispatch. So you're essentially benchm

State of HTTP Servers in Nim

2023-04-14 Thread termer
It's only slightly slower as long as the body is less than or equal to the read buffer size. I think I got about 200k requests per second with bodies.

State of HTTP Servers in Nim

2023-04-14 Thread termer
@junelac >While I understand the frustration, I find the language here very harsh for the people giving away they work for free. Nim has no google or mozilla behind to fund it and generate hype. I have a high standards, and while I understand open source without huge backing has problems, I'm n

State of HTTP Servers in Nim

2023-04-14 Thread pwernersbach
How is the performance of microasynchttpserver when your code reads the bodies?

State of HTTP Servers in Nim

2023-04-13 Thread federico3
> Most people's solution to the HTTP server problem seems to be "put it behind > Nginx." Not only is this ignoring the problem (why should your application > server NEED to be behind a reverse proxy?), Sorry for the sidetrack. Running web services behind Nginx (and often behind external load ba

State of HTTP Servers in Nim

2023-04-13 Thread junelac
While I understand the frustration, I find the language here very harsh for the people giving away they work for free. Nim has no google or mozilla behind to fund it and generate hype.

State of HTTP Servers in Nim

2023-04-12 Thread termer
Multithreaded performance on microasynchttp server is INSANE, it blows Chronos out of the water. I'm getting over 200k requests per second on my desktop, I was only getting about 130k with Chronos. I'll have to do some more testing, but memory seems pretty stable hovering around 40mb when I use

State of HTTP Servers in Nim

2023-04-08 Thread termer
I initially dismissed it when @exelotl mentioned it because it was threaded, but the ability to stream requests might make it a good choice for many things. I still can't use it for everything since it lacks streamed responses, but provided it performs well enough, it may be useful for almost ev

State of HTTP Servers in Nim

2023-04-08 Thread termer
I'll see what I can do during the weekend. I'd at least like to see if I can get it working and what performance it has. The biggest problem I tend to have is memory leaks, the second biggest being low performance.

State of HTTP Servers in Nim

2023-04-08 Thread boia01
FWIW, [GuildenStern](https://github.com/olliNiinivaara/GuildenStern) \-- already mentioned in this thread -- supports streaming of requests. See the [ctxstream](https://olliniinivaara.github.io/GuildenStern/ctxstream.html) documentation. It also supports pluggable protocol handlers in case you w

State of HTTP Servers in Nim

2023-04-08 Thread pwernersbach
No problem, glad to help! We definitely need more production software written in Nim. If you get microasynchttpserver adapted to modern Nim, or even half way, I’m happy to accept a finished or work-in-progress PR for it. Judging by this post, there’s still a need for microhttpserver. Also, two

State of HTTP Servers in Nim

2023-04-08 Thread termer
This might be just what I need. I'll see what I can do to adapt it to modern Nim when I get some time this week. Thanks for showing this.

State of HTTP Servers in Nim

2023-04-08 Thread pwernersbach
In 2017, I wrote a backend service in Nim that had the following requirements: 1. CPU and memory bound (in different parts of the business logic) 2. HTTP API 3. Dozens of simultaneous HTTP API connections 4. Each client POST’ing 64MB of data. Due to (3) & (4), the cost of buffering each

State of HTTP Servers in Nim

2023-04-08 Thread termer
I just filed an issue with a reproducer program and instructions:

State of HTTP Servers in Nim

2023-04-07 Thread arnetheduck
> 4\. Chronos We (Status) are actively working on this one - a memory leak can be frustrating indeed which is why we spent a lot of type making sure that the core of chronos is free from cyclic memory allocations and other memory-consuming annoyances - if you've found a memory leak somewhere, t

State of HTTP Servers in Nim

2023-04-07 Thread guzba
Oh, one more thing (sorry to flood this post...) you can raise the max body size in Mummy (newServer optional parameter). I know it still won't work for you which is all good, but if you do some other testing or whatever I just want to mention it. If you already saw that and know, pls ignore.

State of HTTP Servers in Nim

2023-04-07 Thread termer
> I was sure that all servers from the techempower was at least a bit tested to > hold big amount of connections. TechEmpower uses a large amount of connections I'm pretty sure, but it also uses HTTP 1.1 pipelining, which is a feature that's only useful in benchmarks, and almost never used in t

State of HTTP Servers in Nim

2023-04-07 Thread guzba
Your taking the time to contribute to httpx is awesome and I do hope you get things working really great. Definitely good luck to you getting that merged. As for the streaming and files and all that mess, I hear where you're coming from. Always more work to be done.

State of HTTP Servers in Nim

2023-04-07 Thread termer
Maybe streaming isn't fundamental, but it does come up often enough to where it makes it very difficult to use most servers. I think the most constructive thing that would solve 99% of the cases where you need to stream I/O would be to have an interface for accepting file uploads and putting the

State of HTTP Servers in Nim

2023-04-07 Thread guzba
For the images case, I suggest streaming is not useful. You'll need it all in memory at some point to do the processing. I'm not actually disputing that streaming can be useful, I just really do think it's far more specific than you do, but it's fine. It's an interesting topic. Agree to disagree

State of HTTP Servers in Nim

2023-04-07 Thread termer
> First, on the topic of receiving large file uploads, having your web server > handling this is just not a good choice for an actual production web service. > It is trivial to create a pre-signed upload url for all of the major object > stores (S3, GCS, B2, R2, etc). This means your clients can

State of HTTP Servers in Nim

2023-04-07 Thread guzba
> With that said, you still need streaming I/O to ingest the files initially. > You need to receive the video to then send it to the processing server which > it will be converted into other formats before being uploaded to S3/B2/etc. > I'm also not oblivious to the fact that you're going to be

State of HTTP Servers in Nim

2023-04-07 Thread termer
As my post described, all webservers I tested have deficiencies either in speed, memory leaks, or deal-breaking missing features. While individual servers excel in some areas (httpbeast is fast in raw request-response performance for example), there is none that satisfies all requirements that

State of HTTP Servers in Nim

2023-04-07 Thread guzba
This was a very high-effort post so I thank you for sharing it. It is very useful feedback for everyone to read. However, in the specifics, I have to question essentially every technical choice you've made given that you've framed things as "toys" vs "production". First, on the topic of receivi

State of HTTP Servers in Nim

2023-04-07 Thread treeform
I totally understand your sentiment. It's frustrating when things don't work efficiently, but have you seen modern project stacks? In my opinion, Nim does a pretty good job compared to the commonly used Python, Node, PHP, and Java for "toy" webservers. I've seen real product sites where the Pyt

State of HTTP Servers in Nim

2023-04-07 Thread inv2004
Very interesting topic. I was sure that all servers from the techempower was at least a bit tested to hold big amount of connections. It would be good to have at least small description how to test it. Another question is about streaming: are there big difference with websocket? The question is

State of HTTP Servers in Nim

2023-04-07 Thread exelotl
It was super interesting to see all the Nim HTTP servers compared like this. I wonder how [GuildenStern](https://github.com/olliNiinivaara/GuildenStern) stacks up? (it's most similar to Mummy I believe)

State of HTTP Servers in Nim

2023-04-07 Thread ringabout
Here is the PR implementing async streaming => thanks to @termer Feedback is welcome.

State of HTTP Servers in Nim

2023-04-07 Thread Araq
Please don't derail this thread with your poor mixed language "solutions", as if the poster doesn't know already about Erlang/JVM/Golang.

State of HTTP Servers in Nim

2023-04-07 Thread 12398890
Nim is perfect for working with Golang, let Golang do the networking stuff, then do some lower level stuff in Nim, and finally combine them using cgo. Problem solved!

State of HTTP Servers in Nim

2023-04-07 Thread alexeypetrushin
Maybe JS backend with Deno/Node could be a way to do IO efficiently...

State of HTTP Servers in Nim

2023-04-07 Thread sotolf
Well as usual "Be the change you want to see" I do work at work over the day, I usually don't have the juice left in me to do "production-ready" code on my time off. I'd rather spend my hobby time doing something I enjoy. Nim is a wonderful langauge, and it's fun to play around with, makes most

State of HTTP Servers in Nim

2023-04-06 Thread termer
This feeds back into my general frustration over the fact that most people are building toys with Nim, rather than working on building production-ready libraries and applications. This problem can only compound because it drives away other people from being able to build real applications. Keep

State of HTTP Servers in Nim

2023-04-06 Thread termer
I've been using Nim for several years now. I mostly use it for small utilities and experimentation on things like microcontrollers. However, most of my time goes into other projects, mostly web-related, and thus I've wanted to integrate Nim into some of my web endeavors. To start working on this