GithubHelp home page GithubHelp logo

Comments (11)

agentzh avatar agentzh commented on August 17, 2024

@eoranged The lua-resty-redis library is based on ngx_lua's cosocket API, which is a parallel implementation to the ngx_http_upstream thing in the nginx core. You can do everything you did with ngx_redis2 + upstream {...} in Lua with lua-resty-redis but you cannot mix these two like accessing upstream {...} entries from within lua-resty-redis.

from lua-resty-redis.

eoranged avatar eoranged commented on August 17, 2024

It is sad, but I got It.

from lua-resty-redis.

agentzh avatar agentzh commented on August 17, 2024

@eoranged why do you still want to keep using your upstream {...} blocks?

from lua-resty-redis.

eoranged avatar eoranged commented on August 17, 2024

@agentzh As I have already mentioned in the question, http_upstream_module provides load-balancing and handles backend fails.

from lua-resty-redis.

agentzh avatar agentzh commented on August 17, 2024

@eoranged You can easily implement failover and load balancing yourself with a little bit of Lua if you're using lua-resty-redis. Also you have much more flexibility here.

See also https://github.com/agentzh/lua-resty-redis#load-balancing-and-failover

from lua-resty-redis.

wonderbeyond avatar wonderbeyond commented on August 17, 2024

Any existing code for reference? whether lua or not.

from lua-resty-redis.

wonderbeyond avatar wonderbeyond commented on August 17, 2024

I've done a very basic redis load balancer module: https://gist.github.com/wonderbeyond/11a20570bb5b1b1bf818bf03e527faf6

I just select the next server from a given list circularly.

from lua-resty-redis.

marius-c avatar marius-c commented on August 17, 2024

hmm is the above example correct ? is that counter shared across all workers / sessions ?

from lua-resty-redis.

wonderbeyond avatar wonderbeyond commented on August 17, 2024

I have used it in production until now.

The counter is shared in one single worker.

from lua-resty-redis.

marius-c avatar marius-c commented on August 17, 2024

yep makes sense. just read the docs. thanks for sharing.

from lua-resty-redis.

wonderbeyond avatar wonderbeyond commented on August 17, 2024

However, I think we need a more powerful balancer module.
e.g. We can report failure of one redis node to the balancer, the balancer will not select it for a period of time.

Are you interesting?

from lua-resty-redis.

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.