Comments (6)
Segfault - my mistake, iIdon't check on null body_string
from facil.io.
I'm a bit busy today, I'll try to be short and fast, if I don't answer everything, I'll write more when I can.
I think you encountered a known issue with the HTTP protocol that was probably (maybe) made worst because your previous code was writing directly to the sockets instead of using an http_response_s
object (this object will optimize parts of the response and make sure it's formatted correctly).
One of the issues in the HTTP/1.1 protocol is that it is VERY expensive to open and close network connections. There's a whole lot of processing required by the kernel as well as a TCP/IP feature called "slow start".
It's even worst if the same client sends a lot of requests (requiring a lot of new connections). Each client has a "cool-down" period for each connection port (about two minutes on many systems) and there's a theoretical limit on how many connection ports each client can use (~64K ports per client for each listening socket)... This is system related, not much we can do about it.
This is a serious issue if you have many requests from a single client.
In normal HTTP settings, Keep Alive should improve performance drastically.
It's also why HTTP/1.1 is being replaced with HTTP/2, why Websockets are often used instead of AJAX and why memcache was using persistent connections instead of HTTP.
The better the server is designed (the server overhead is low), the higher the performance gain for Keep Alive (the more you notice the issue with the TCP/IP layer).
For facil.io, Keep-Alive should improve performance at a X20 rate (%2000)! This is similar to nagging and it's partly because facil.io is relatively fast with a small overhead. On other systems you might see smaller improvement (they have higher overhead).
HOWEVER, I suspect some of the delays were because of the way the old code you used in the test was handling response issue.
In the old code you wrote to the socket directly. This can cause HTTP errors in relation to the Content-Length
header...
...When this happens, the client (curl
) might wait for a disconnection before it realizes that the response is complete. Unless you manually close the socket, you are actually waiting for the HTTP timeout to occur (the default is 5-6 seconds).
...
from facil.io.
As to the segfault
, I'm not sure where it's coming from.
However, would you mind experimenting with me?
If you add -DASYNC_USE_SENTINEL=1
to the CFLAGS in the makefile
(or update the value in libasync.c
), than the server will try to listen to error signals and it will try to recuperate after some errors without crashing. It will also print an error report with a backtrace of the stack, so you have more information about what happened.
from facil.io.
Oh, I just noticed you know what happened... forget about it :-)
from facil.io.
Thank you Boaz! Your code very well commended, i will read it!
from facil.io.
You're very welcome.
If you find that the keep-alive is slower than it should be or anything else, please let me know.
If there's anything wrong I would like to fix it. Having false alarms is better than not knowing :-)
Thank you for opening the issues.
from facil.io.
Related Issues (20)
- A route handler for Facil.io
- Build facil.io into an DLL? HOT 4
- Compile on Apple Silicon M1 HOT 3
- In the example there is facil_run but I don't see this function? HOT 2
- Do you need a main() function if you are just building the shared object library? HOT 1
- fiobj_mustache.c: No folder argument HOT 1
- Passing variables to Mustache does not seem to work HOT 4
- Support for redis UNIX sockets HOT 1
- How to install this framework?
- Potential concurrency issue? Wrong file names on some requests. HOT 4
- crashed on FIOBJ_TYPE_IS(fiobj_null(), FIOBJ_T_NUMBER) HOT 2
- C++ compilation support? HOT 2
- Facil and linux epoll HOT 2
- How to receive an img file? HOT 1
- make breaking on macos m1 HOT 1
- compiling facil to shared library to be called from julia HOT 16
- trying to build native binaries for julia HOT 4
- Get form parameter
- Unlimited threads in facil.io - 0.7.x HTTP / WebSockets Server HOT 1
- OpenSSL Not Detected HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from facil.io.