Code Monkey home page Code Monkey logo

Comments (4)

segler-alex avatar segler-alex commented on May 24, 2024

i have to add one or more things:

  • only construct the list of servers on program start, and than randomize it and then start by using the first server
  • on error, continue by using the second in the already in the first step randomized list.
  • please do not call /json/stats at all just for checking if it works. the best way to do it is just using the server. and if it does not work fall back to the next in the list

at the moment traffic is no problem, but i want to optimize this early on, traffic will grow to the servers.

from tuner.

louis77 avatar louis77 commented on May 24, 2024

Hi @segler-alex

Thank you very much for creating this issue and keeping an eye on this little project!

You may have seen some code that is commented out. In the commit I do loop over the list of servers and check for a HTTP 200 on /json/stats until the first sucessfull response. So most likely it will always choose the first server, which is a static list of the three currently available servers. I've also reviewed the Grafana traffic stats and noticed that de1 has a lot of traffic compared to nl1 and fr1, so I will randomize the list πŸ‘.

Having said that, I ran into an issue using the proposed strategy as described on https://api.radio-browser.info/. While doing a DNS resolution on all.api.radio-browser.info is fast and straightforward, reverse-resolving the hostnames (3 x IPv4 and 3 x IPv6) takes too much time. I've tried to use the API server with IPs only but then the API didn't respond properly so I assume there is a virtual host config in place.

This is why for now I have hard-coded the list of the three servers just to speed up this process, which is done before the App window appears on the screen.

Maybe you want to implement a strategy using DNS SRV records: https://en.wikipedia.org/wiki/SRV_record
or just put CNAME records on the DNS zone so reverse-resolving the IP addresses will not be required any more?

So this is what I'll do for now:

  • Step1: Randomize the list of servers on startup
  • Step2: Remove the need to check on /json/stats by implementing a retry strategy based on the randomized list of servers from Step1
  • Step3: Dynamically fetch the list of servers using DNS requests in the background and store that list in the app settings so it will have to be done on every app start

from tuner.

segler-alex avatar segler-alex commented on May 24, 2024

hi, thank you for the tip with SRV records, i did now create them. you can check with (on linux shell):
$ dig _api._tcp.radio-browser.info SRV
or on the web with
https://mxtoolbox.com/SuperTool.aspx?action=srv%3a_api._tcp.radio-browser.info&run=toolpage

this is really helpfull because as you said, it does not need a reverse lookup but gives you directly a list of server names.
could you try it and use it?

i do not understand what you meant with CNAME. could you explain further what to do there?
CNAMEs are just links to other DNS names, but they get translated to IPs and that is not what a client would need. you need the real name because of the SSL certificate. the certificate references the name and is only legal if you use the real name (de1.api.radio-browser.info for example)

from tuner.

segler-alex avatar segler-alex commented on May 24, 2024

i added the DNS SRV records as alternative to the documentation at https://api.radio-browser.info/

from tuner.

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.