High Performance Networking in Google Chrome
igvita.com
igvita.com
Chrome only needs WinXP SP2, while still supporting Mac and Linux.
This is a big deal at least with my customers. It's just silly that Chrome has broader Windows support than IE. IE should not be so dependent on the base OS.
What is clear is that the chrome development organization is built to release all the time in perpetuity (just like web, mobile development). Not sure this is true for MS.
Basically, if there are multiple IP's behind a hostname, connect a non-blocking socket to each, then do a select/poll/epoll/kqueue on all of them. Then, once at least one returns, immediately close the rest and use the newly established connection.
This has three nice side-effects. First, if one of the hosts is down, it will never be selected, unlike now when there is a 1 in N chance that you'll be stuck waiting for a very long time. Second, you don't need to explicitly check whether the IPv4 vs IPv6 stacks are operational. A connection that is returned to you is the one that works, regardless of the underlying protocol. Third, this provides crude load balancing. Presumably the host that connected the fastest is also the fastest to process your request. The my blog post for some numbers.
Even if Chrome had only 10% of its current features, I appreciate the fact that it provided competition into the browser market and spurred innovation by _everyone_. The benefit to the internet community as a whole is tremendous.
I wonder if someone could extract that lib into its own project. It would be great to have a version of AFNetworking or Python's requests library built on top of this -- in order to take advantage of the advanced socket reuse and late binding stuff that he describes in the article.
But that's all without really looking at the code. Maybe there's just too much Chrome-specific stuff there.
In short, we don't want to support other consumers, sorry. Feel free to do code drops, they should work fine.
Talking about web browsers, I can't wait for the next big step. Mozilla and Google are already moving ahead: When web browsers become the whole OS. With web apps becoming fully capable, and with native apps increasingly network integrated, the distinction is becoming meaningless.
In that vision of web browsers as OSs, there is a big limitation. More than some still incomplete APIs, or a few ones still missing, the problem is the whole development story. Web development is still a chaos. The web platform, is a soup with far too many ingredients. Why we still have to develop application's UIs, using a document markup engine?.
The web is rich. There are all kinds of resources. It is non-sense to express all of these resources, with a single development paradigm: html-css-javascript. Native development, is more flexible. There is the possibility of choosing the right tool for the job. I hope that one day not so far away, browsers will gain similar capabilities. Support for multiple separated, specialized development environments.
At each step, not everyone will be 100% happy with how things are organized, but enough of it will work that it expands the frontier of what kinds of software can be built on the web. We've been through this before - the web has worked because its paradigms keep getting stretched beyond expectations.
https://code.google.com/p/chromium/issues/detail?id=170595
the chrome.socket API is really awesome, it can listen to tcp/udp connections, works like a mini NodeJS. It's a shame they didn't make it more stable.
How to catch that error? There's no exception callback in the doc
http://developer.chrome.com/apps/socket.html
And if the port is already blocked, how to recover?