Comments (3)
It’s not so much a reimplementation, just a different approach.
While the standard Go net package also uses kqueue/epoll under the hood, it requires that you demultiplex incoming connections by firing up one goroutine per connection. This concurrency is desirable in most cases, and it requires that shared data is protected from race conditions with a mutex, atomic, or perhaps channels.
The shiny package uses the Reactor pattern where all events fire from the same goroutine that the server started on. There’s no concurrency at all, it’s totally single-threaded.
This single-threaded event model eliminates all context-switching and can often speed up execution. This allows for Go to be used as a language for creating very lightweight network services such as proxies, load balancers, and caching engines. Think Haproxy, Nginx, Redis, Memcached, etc.
My desire is to use Go for ultra lightweight appliance-like services that run well on hardware with limited resources.
from evio.
You're confusing concurrency with parallelism. The go runtime does not schedule one goroutine per thread. A heavy concurrent Go program can run on a single thread with no issue.
Check out runtime.GOMAXPROCS.
Goroutines are made to be really lightweight, actually, you can implement the reactor pattern using them and you would probably have the same performance. Of course, there's no way of knowing for sure if there are no proper benchmarks for comparison.
from evio.
You're confusing concurrency with parallelism. The go runtime does not schedule one goroutine per thread. A heavy concurrent Go program can run on a single thread with no issue.
I'm not confusing the two. I understand the difference. I never mentioned using goroutines equates to using more than one thread. I did say that using Shiny equates to using one thread.
Check out runtime.GOMAXPROCS
GOMAXPROCS makes the entire Go application run on one CPU. I'm not interested in making my services single-threaded, I'm interested in making a single-threaded networking event model.
Goroutines are made to be really lightweight
True they are made to be really lightweight.
you can implement the reactor pattern using them
True you could implement the pattern.
and you would probably have the same performance
False. In the lab Shiny is faster and more memory efficient.
Of course, there's no way of knowing for sure if there are no proper benchmarks for comparison.
Of course there's a way to know. I know. I've been goofing with this stuff for quite a while. And if you want to know you can goof with it too.
I have plenty of proper benchmarks for this (experimental, work-in-progress) project. And if and when this project is something that I consider stable, I may add them to the repo.
from evio.
Related Issues (20)
- Panic will occur when accepting HOT 1
- How to Async write? HOT 2
- how to write to Conn from another goroutine? HOT 1
- What is the purpose of these lines? HOT 1
- How to limit the maximum number of connections ? HOT 1
- I think writing to the output buffer wrong in examples (http server/ redis server) HOT 1
- how to performance push service ? HOT 1
- Calling Wake() on UDP conn does nothing
- CPU consuming 100% HOT 5
- how does hmget return values? sorry i'm not sure how to use appendbulk etc without examples.
- any intent to make http into a full fledge http server like fasthttp?
- Using channels
- Any reverse proxy example?
- In the linux tcp epoll mode, some conditions will lead to starvation when reading, as well as data loss and repeated sending problems in the buffer to be written in the connection HOT 1
- numLoops > 1 will make udp server slower HOT 2
- Calling wake should append c.out, instead of saving only last output call
- [question] why use count field in loop not len(fdconns)?
- Differences with other libraries HOT 1
- how to send data to other conn?
- how to get receive data after conn.wake in events.Data?
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 evio.