jdev - 2019-11-22


  1. dandan

    I have a question about DNS SRV setup for xmpp server for a cluster of XMPP servers. Anyone able to help?

  2. Link Mauve

    dandan, ask your question, if someone can answer they’ll do so.

  3. Link Mauve

    They can’t if you don’t ask.

  4. dandan

    Sure, Thanks.

  5. dandan

    The question is that I have a cluster of 2 nodes (very simple) deployed on AWS.

  6. dandan

    I have setup DNS SRV records correctly (hopefully) for all servers.

  7. dandan

    Now the question is that in case I do not use a load balancer for my servers, to what address should my clients connect to?

  8. dandan

    For instance if my configuration is as below: 0 5 5223 server1.mydomain.com 0 5 5223 server2.mydomain.com for _xmpps-client._tcp.mydomain.com then to what address should my clients connect?

  9. dandan

    should they connect to server1.mydomain.com or server2.mydomain.com?

  10. Zash

    yes

  11. Zash

    they should pick one of them with about 50/50 chance

  12. dandan

    Yes but that would be up to the client then and different from what load balancer is.

  13. Zash

    yes

  14. dandan

    As far as I have understood, these records are supposed to do the work of load balancer.

  15. Zash

    but what you pasted amounts to 50/50 load balancing

  16. Link Mauve

    dandan, without any software required in front of your server.

  17. dandan

    What do you mean Link Mauve?

  18. dandan

    Ah sure. Yes. I mean no load balancing will be needed in that case. But how the client should decide what server to choose? The client has no idea about the load.

  19. Zash

    dandan: if you want more control then use a load balancer

  20. Link Mauve

    dandan, it will pick one at random, throw a coin, and go for that one.

  21. moparisthebest

    The client literally flips a coin

  22. Link Mauve

    flip*, that’s the word.

  23. Link Mauve

    Thanks. ^^

  24. dandan

    Ok then. I see.

  25. Zash

    but if it for whatever reason can't establish a connection to the chosen one it should try the other

  26. dandan

    I see. Well is it really realiable? I mean a NLB seems to be a better solution, or?

  27. Zash

    No idea what "NLB" is

  28. dandan

    Network Load Balancer

  29. Zash

    It's up to you

  30. Zash

    more moving parts etc

  31. dandan

    If this is totally random by the client side, so why the wight is decided on the server side in DNS record?

  32. moparisthebest

    dandan: refer to the algorithm here https://tools.ietf.org/html/rfc2782

  33. dandan

    I mean 50%, 30%, etc.

  34. Zash

    dandan: that's what the second number is

  35. Link Mauve

    dandan, because the administrator might have provisioned different size of servers.

  36. Link Mauve

    So they prefer clients to flip a four-faced coin and go 25% of the time to one physical server, 75% of the time to another one.

  37. Link Mauve

    Or any other possible combinaison.

  38. Zash

    dandan: in your example you have 5 and 5 as weight. so each entry should have a 5/10 = 50% chance of being selected first

  39. dandan

    Yes I know. This is an example.

  40. dandan

    OK. Then so if I have 4 servers of shared load of 50%, 30% and 20% then I should flip a dice of 3 sides with respective probabilities?

  41. Zash

    if you set up SRV records like that, yes

  42. dandan

    OK thanks. One more question if you don't mind.

  43. dandan

    Is it OK not to set DNS SRV records and just go for load balancer?

  44. Zash

    of course

  45. Zash

    altho for xmpps you do need them

  46. dandan

    I am asking because for instance Openfire will complain when DNS SRV records are not set.

  47. Link Mauve

    For normal _xmpp-client record (non-xmpps), you need either a SRV record or a A record, if the user will only ever connect to a single server (or load-balancer).

  48. Guus

    Openfire will warn, but will operate fine.

  49. Link Mauve

    You can set both but the end result will be identical.

  50. dandan

    Yes I have observed that it work as it should but I was wondering if this is recommended to set DNS SRV records or not.

  51. dandan

    Yes sure. The result will be identical as you said.

  52. Link Mauve

    You only need a SRV record if you plan to use xmpps (XEP-0368), or if you want to use the inherent “load” balancing SRV provides with multiple records.

  53. Guus

    or if you want to run a cluster

  54. dandan

    I run a cluster.

  55. Guus

    or if you run on a server for which the host name doesn't match the XMPP domain name

  56. Zash

    or if you wanna use a non-standard port or point at a different machine/A record

  57. dandan

    and want it to be scalable.

  58. Zash

    (what Guus said)

  59. Guus

    generally, DNS SRV records are good.

  60. Guus

    Openfire should give you concrete examples of DNS SRV records suitable for your instance.

  61. Zash

    dandan: If I were you I'd worry about using a separate load balancer later if it turns out you need one

  62. Guus

    but a general grasp of the concept is good to have, so that you can make informed decisions.

  63. dandan

    Yes I know. But I mean if I use a load balancer then I don't need to set DNS SRV records that are recommended by Openfire.

  64. Zash

    It's easy to change DNS

  65. moparisthebest

    dandan: what's the point of a cluster if you put a single point of failure load balancer in front?

  66. Guus

    (capacity, probably)

  67. dandan

    Well, I might be wrong, but by having a cluster I will be able to have fail-over config and scale the system.

  68. Guus

    dandan, it won't fail over a failing loadbalancer.

  69. moparisthebest

    He said AWS, isn't it cheaper to run 1 big server vs 2 small?

  70. dandan

    The load balancer in AWS AFAIK is not a single point failure system since the load balancer itself will be scaled. I might be wrong though.

  71. Guus

    Oh, I dropped in half way through the conversation - I missed that.

  72. Link Mauve

    Fail-over is also definitely possible with SRV records, if the coin flipped by the client leads it to a dead end^Wserver, it will fallback to the other one(s).

  73. Guus

    but yeah, DNS SRV records are less complex by an order of magnitude

  74. Guus

    that's generally good.

  75. Guus

    a lot cheaper too, presumably

  76. Zash

    you can have 1 5 5222 first-choice.example.com 2 5 5222 second-choice.example.com etc

  77. moparisthebest

    dandan: are you running them both in the same AWS datacenter too?

  78. dandan

    Yes Zash?

  79. dandan

    Then choose randomly between them?

  80. dandan

    Yes mopasisthebest.

  81. moparisthebest

    dandan: so single point of failure again

  82. Zash

    dandan: no, they get tried in order of the priority (first number)

  83. moparisthebest

    Whole AWS datacenters fail often

  84. Guus

    dandan i suggest you read up on DNS SRV. They're pretty versatile, and easy to work with. You can always invest in load balancers if you feel that DNS SRV doesn't suit your needs.

  85. dandan

    Thanks Guus.

  86. Guus

    wikipedia comes with a handy example

  87. Guus

    Ok, I'm off to bed

  88. dandan

    Zash the question is that how the client will know that for instance the first server is loaded and chose the second one?

  89. Zash

    dandan: it doesn't

  90. Zash

    dandan: it sorts the records by priority and if there are multiple with the same priority it'll shuffle them and pick by weight. if the connection fails it removes that one and tries the whole thing again (roughly)

  91. Zash

    the RFC moparisthebest linked explains how it works, I recommend you read it

  92. Zash

    and as I said, if you need more control then use a load balancer

  93. moparisthebest

    But you probably don't, and regardless don't run all your services in the same DC if you are after reliability

  94. dandan

    Yes you are right.

  95. dandan

    I will read the link that moparisthebest sent.

  96. Zash

    load balancing and high availability at the same time is non-trivial. most xmpp clustering solutions are focused on load balancing afaik

  97. dandan

    Definitely need to read more about it.

  98. dandan

    Zash you mean that the clients have knowledge about all servers that a DNS SRV record has been assigned to it?

  99. Zash

    I don't understand the question

  100. dandan

    Like your example, a client will also have the list of all serves you listed?

  101. Zash

    client would query for the SRV records, receive a list

  102. dandan

    first-choice, second-choice ?

  103. Zash

    ?

  104. Zash

    If you query for _xmpp-client._tcp.example.com you get an aswer with all the SRV records there

  105. dandan

    Aha ok. That is what I wanted to know. Is there any special command for querying in XMPP client libraries like Smack for instance or this should be done in other ways?

  106. Zash

    then it follows the sorting algorithm and tries to connect until it gets a connection or runs out of options

  107. Zash

    I know nothing of Smack, can't help you with that.

  108. dandan

    OK. Thanks a lot all of you for your kind help.

  109. guus.der.kinderen

    Smack does SRV lookup by default

  110. guus.der.kinderen

    It'll actually warn you if you're connecting to a domain that has no SRV records