Skip to content
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

[WIP] uWebSockets Integration #2367

Closed

Conversation

timkendall
Copy link

@timkendall timkendall commented Feb 24, 2019

This is the beginnings of a new integration with uWebSockets.js, a spicy new super-fast native HTTP framework replacement for Node.

I've gotten the basic functionality working but a few things still need to be tackled (and some things may be blocked by uWebSockets right now).

TODO

  • Support file uploads
  • Support subscriptions
  • Fix janky tests that require a random free port to be chosen (may be an issue with something I'm doing but I couldn't seem to get it to cleanly give up the port even following their GracefulShutdown example)
  • Add support for fully constructing Request objects before passing to runHttpQuery (see Need getHeaders() uNetworking/uWebSockets.js#70)
  • Solidify what we want to pass to createGraphQLServerOptions (have to be very careful with the req/res objects given to us by uWebSockets so we may want to pass "fake" versions of them with basic data copied out)
  • Fix a handful of failing tests

Apollo TODO:

  • Update CHANGELOG.md with your change (include reference to issue & this PR)
  • Make sure all of the significant new logic is covered by tests
  • Rebase your changes on master so that they can be merged easily
  • Make sure all tests and linter rules pass

Closes #2353

@apollo-cla
Copy link

@timkendall: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Meteor Contributor Agreement here: https://contribute.meteor.com/

@orefalo
Copy link

orefalo commented Feb 26, 2019

Neat! exactly what I was trying to build

@timkendall
Copy link
Author

@orefalo ha I saw your issue in uWebSockets and thought so :) Would love your help on this if you have time.

@ghost
Copy link

ghost commented Mar 4, 2019

@timkendall Hello, could you please explain more about the graceful shutdown issue?

@timkendall
Copy link
Author

timkendall commented Mar 5, 2019

Hey @alexhultman , yeah to elaborate I was seeing app.listen fail to return a listen token when attempting to startup the server before each test (was happening when I was calling destroyApp after each test which I'm not right now)

describe('integration:uWebSockets', function () {

When I switched to using random free ports (like I'm using right now) the problem went away (i.e got that listen token successfully).

Again, could just be something that I'm doing wrong ;) Super spicy work btw 👍

@mtsewrs
Copy link

mtsewrs commented Mar 6, 2019

@timkendall What kind of speeds do you get with a simple hello world query? Tested your code on a hello world query on osx and got 8.5K req/sec.

@timkendall
Copy link
Author

Looks like uWebSockets.js v15.6.0 has support for getting all headers from a request. Will be adding this.

https://github.com/uNetworking/uWebSockets.js/releases/tag/v15.6.0

@orefalo
Copy link

orefalo commented Mar 15, 2019

@timkendall What kind of speeds do you get with a simple hello world query? Tested your code on a hello world query on osx and got 8.5K req/sec.

I didn't benchmark with apollo yet. But the core library is 50% faster than bare metal node.
https://github.com/orefalo/turbo-http/tree/master/benchmarks

┌──────────────────────────┬────────────┬─────────┬───────────────┐
│                          │ Requests/s │ Latency │ Throughput/Mb │
├──────────────────────────┼────────────┼─────────┼───────────────┤
│ uws.js                   │ 75211.2    │ 6.95    │ 5.38          │
├──────────────────────────┼────────────┼─────────┼───────────────┤
│ turbo-http.js            │ 64627.2    │ 7.63    │ 4.87          │
├──────────────────────────┼────────────┼─────────┼───────────────┤
│ bare-node.js             │ 50165.6    │ 9.77    │ 5.55          │
├──────────────────────────┼────────────┼─────────┼───────────────┤
│ polka.js                 │ 49209.46   │ 9.94    │ 5.44          │
├──────────────────────────┼────────────┼─────────┼───────────────┤
│ rayo.js                  │ 48861.82   │ 10.02   │ 5.41          │
├──────────────────────────┼────────────┼─────────┼───────────────┤
│ fastify.js               │ 43109.6    │ 11.23   │ 6.45          │
├──────────────────────────┼────────────┼─────────┼───────────────┤
│ express.js               │ 40096.37   │ 12.11   │ 4.44          │
├──────────────────────────┼────────────┼─────────┼───────────────┤
│ hapi.js                  │ 19007.6    │ 25.04   │ 2.83          │

It behaves particularly well under heavy load.

@orefalo
Copy link

orefalo commented Mar 15, 2019

@mattiasewers could you share your benchmark code, tks

@mtsewrs
Copy link

mtsewrs commented May 10, 2019

@orefalo This is no longer an issue with res.experimental_cork

@hayes
Copy link

hayes commented Aug 19, 2019

I've been looking at how to integrate apollo with uWebsocket.js, was there a technical reason this stalled out?

@timkendall
Copy link
Author

@hayes not really, just got busy (upload support may be a little involved but we don't need to do that right away :)

@hayes
Copy link

hayes commented Aug 20, 2019

I looked a bit at what it would take to get subscription support (my use case) and that looks a bit more involved. There are a lot assumptions around having nodes request/connection objects in the ws transport package.

I'm not sure if I'll have the time to figure out how to make that compatible.

@orefalo
Copy link

orefalo commented Aug 21, 2019

"I've been looking at how to integrate Apollo with uWebsocket.js, was there a technical reason this stalled out?"

I personally dropped uWS, the author is way too arrogant and egocentric... rude would be a more appropriate term.

@hayes
Copy link

hayes commented Aug 21, 2019

That's discouraging to hear. It may not be worth it in this case. Mostly just exploring options at this point

@ghost
Copy link

ghost commented Sep 5, 2019

@orefalo I checked our email conversation and I find nothing but polite conversation from both ends. You stopped emailing me when I told you my hourly rate.

Of course, you interpreted my disapproval of your idea as "rude". If you want to hire someone only to confirm your original idea, without any critical thinking, then hire an actor or diplomat. You can't expect everyone to agree with your direction just because you wave a couple of dollar bills around.

That's called confirmation bias - you look for someone to agree with your idea rather than look for objective input to challenge your idea until the idea is either right or wrong, proven by evidence.

Alright, take care.

@abernix abernix closed this Jun 24, 2020
@abernix abernix reopened this Jun 25, 2020
@abernix abernix changed the base branch from master to main June 25, 2020 09:04
@maxpain
Copy link

maxpain commented Dec 19, 2020

Any update on this?

@orefalo
Copy link

orefalo commented Dec 20, 2020

it's dead - if you want speed and scalability, switch to go and rust. you will get both without the arrogance. cheers

@ghost
Copy link

ghost commented Dec 20, 2020

the arrogance

Ah yes because a middle aged Rolex wearing narcissistic "I model, therefore I am" kind of man who cannot take a "no" is never at fault.

You are mad because I turned down your idea and had a too high rate, and now you act like a 5-year-old who won't get the newest Transformers toy for Christmas.

If I remember correctly you acted like an inflated overly proud alpha cat with stiff tail pointing straight up and thought you could just come and throw (way too little) money at me and have me automatically agree with anything.

@orefalo
Copy link

orefalo commented Dec 20, 2020

Good,
You are starting to show your real self again Alex:rudeness is popping again in your jargon. But this time around you won't be able to delete the thread, right?
I believe you have a real personalty disorder... plus memory issues. it's laughable: you are pissing off so many people you can't even remember which is which.
Go reply with your insults...

@ghost
Copy link

ghost commented Dec 20, 2020

Relations require chemistry and it's clear that we both dislike each other so let's just leave it at that. We don't need to be friends.

@timkendall timkendall closed this Dec 20, 2020
@maxpain
Copy link

maxpain commented Dec 22, 2020

I've done integration here

@apollographql apollographql locked and limited conversation to collaborators Dec 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Integration with uWebSockets.js
7 participants