Giter VIP home page Giter VIP logo

Comments (3)

tidwall avatar tidwall commented on August 17, 2024

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.

noonien avatar noonien commented on August 17, 2024

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.

tidwall avatar tidwall commented on August 17, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.