-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
samples: sockets: Add a dumb HTTP server example #1378
samples: sockets: Add a dumb HTTP server example #1378
Conversation
This is a sockets test application I wrote while developing BSD Sockets API. I didn't submit it at that time, because it seemed to dumb, plus I wanted to it to be an example of serving a real page, not a handful of characters, and that hit issues deep in the stack which I wanted to investigate first. Anyway, it's definitely useful to do load testing on BSD Sockets API and to uncover regressions like https://jira.zephyrproject.org/browse/ZEP-2593 . |
https://jira.zephyrproject.org/browse/ZEP-2593?focusedCommentId=19957&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-19957 was updated with instructions how to use this sample to reproduce queue operations performance regressions introduced by 84db641 |
src/socket_dumb_http.o: src/response.inc | ||
|
||
response.inc: response.html | ||
bin2h 8 <$^ >$@ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This requires that you have bin2h somewhere. At least in my host (Fedora 25) I do not have it.
One option could be that I send the patch "samples: net: common: Add rules to generate a header file" (currently found in websocket patchset) separately as there could be some use for it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those lines are actually artifact of experimentation, which didn't work still. Instead, I included pre-generated *.inc files into this PR (and standalone Makefile.gen file to re-generate them). But indeed, this:
that I send the patch "samples: net: common: Add rules to generate a header file" (currently found in websocket patchset) separately as there could be some use for it here.
would be better, I'd appreciate it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created a separate PR #1447 that contains one way to create an include file.
35dce9a
to
98d1803
Compare
839866f
to
237e5a9
Compare
Updated to use the latest version of #1447. |
237e5a9
to
7c2ce51
Compare
Updated to the latest version of #1447 |
6532b53
to
30e0d9c
Compare
CI fails due to false positive:
That file should have \r\n line endings in the HTTP response part, as can be seen I event tried to rename it to .bin to deter checkpatch from poking into it, but that didn't help. @jukkar : Please re-review/approve. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What about just having \n and remove \r, usually the clients are not very strict about that. |
Usually, yes, but that's violation of the protocol! |
Hardly a big issue for a sample application with test content. |
I think it is. This app tests (per 2nd in row intention behind it) ability to handle multiple client connections. It's not intended to test how much clients are tolerable to malformed protocol replies, and testing both at once is a bit too much (the best practice is to test one thing at time). @jukkar, so, I'd appreciate if this can be merged as is. If you can't do that because of a false positive CI failure, and it requires override from e.g. @nashif, please let me know that, so I can pursue it. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs a readme explain what exactly are you doing here and why this is useful and we also need a sample.yaml to build this in CI.
da7548a
to
ebb21f6
Compare
88e7fee
to
2860a83
Compare
@nashif : Both are now added. |
Finally, you can run an HTTP profiling/load tool like Apache Bench | ||
(``ab``) against the server: | ||
|
||
$ ab -n10 http://192.0.2.1:8080/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's a space required here, -n 10
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not "required", but optionally can be used. Unless there's strong affinity for Zephyr docs to use space form when quoting params for any external apps which supports both, let's leave it as is (at least it's shorter)?
|
||
$ ./socket_dumb_http | ||
|
||
To test, connect to http://127.0.0.1:8080/ . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add, "as described in the previous section."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Taken literally, that sounds confusing, because previous section didn't describe connecting to http://127.0.0.1:8080/ . Instead, rewrote as:
"To test, connect to http://127.0.0.1:8080/ , and follow the steps in the previous section."
<p> | ||
The Zephyr kernel is derived from Wind River's commercial VxWorks Microkernel Profile for VxWorks. Microkernel Profile has evolved over 20 years from DSP RTOS technology known as Virtuoso. The RTOS has been used in several commercial applications including satellites, military command and control communications, radar, telecommunications and image processing. The most recent example of the technology’s success is the successful Philae Landing on Comet Churyumov–Gerasimenko and the accompanying Rosetta Orbiter. | ||
</p> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and you're missing the closing </td></tr>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Browsers can deal with that, no worries ;-). And yep, that was more or less crude copy-paste from the Zephyr website homepage at that time. Fixed though.
|
||
``-n`` parameter specified the number of HTTP requests to issue against | ||
a server. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add here a section that shows how you can update the sample to reply with an bigger HTML response (change an #if 0 to #if 1)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I don't know if it's worth to describe such features. That feature is developer-oriented, the docs is user-facing. There can be various different developers' features, they may change over time.
Content-Type: text/html; charset=utf-8 | ||
|
||
<html> | ||
<style> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically this is malformed HTML. Need to add a section (where the <style> would go).
Also, you don't talk about this "big" response in the documentation. Looks like you could tweak the code to get this big response if you wanted to...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically this is malformed HTML.
Depends on which HTML ;-). For pre-5, based on XML with omitted and implied tags, it may be even valid, and browsers definitely can deal with it. Happy to add <head> there of course. The point - if you keep looking, you may find more artifacts, but it was tested to work with the browsers...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggested edits
It's dumb, because it doesn't really parse HTTP request, just always sends the same page in response. Even such, it's useful for socket load testing with tools like Apache Bench (ab) and for regression checking in the net subsystem. Signed-off-by: Paul Sokolovsky <[email protected]>
2860a83
to
758f9e2
Compare
@dbkinder : Addressed what made sense IMHO, would prefer to keep "response_big" feature an internal one - those who'll poke in the source will find it. Will be happy to make it the default later - when the IP stack will be able to run reliably with it. |
…phyrproject-rtos#1378) Signed-off-by: Geoff Gustafson <[email protected]>
It's dumb, because it doesn't really parse HTTP request, just always
sends the same page in response. Even such, it's useful for socket
load testing with tools like Apache Bench (ab) and for regression
checking in the net subsystem.
Signed-off-by: Paul Sokolovsky [email protected]