• Joe (unregistered)

    It works as coded. All those names probably point to the same server in someone's basement anyway, so no problem.

  • (cs) in reply to dgschrei
    dgschrei:
    With this implementation, if one of the 4 servers fails 25% of all download requests will time out and not be served.
    Given that they, effectively, distribute malware, I'd consider it a very good thing indeed. IOW: It's a less-of-a-WTF only because the whole thing is just so bad.
  • Jeremy (unregistered)

    We get it, in a "real" load balancer you can drop and add servers willy nilly. That doesn't make this a WTF.

    It was executed by someone that had never heard of randoms or modulus, or whatever other ways could have not made it a repetitive and oddly grouped mess, sure. That said, I'm not sure I get this "you either go 100% to a real load balancer or it's 100% useless" attitude. This still spreads some of the load around. Yes, if a server goes offline 1/3 of the people are SOL, but is that any worse than 100% of the people if the one server goes away?

  • Walky_one (unregistered) in reply to A Guy
    A Guy:
    Walky_one:

    if (a = 0) UseServer1; [...]

    This works too... I still would qualify it as a WTF.

    odd definition of 'works': always going for Server1

    (or are the '=' just 20 typos?)

    Typos... I'm currently in "Delphi" mode (which uses single "=" for equal testing and ":=" for assignment). When switching to C++ / C# / Java (and back again) it's always the same issues...

  • (cs)
    the submission landed in our Submissions Inbox back in 2011
    Ladies and gentleman, I give you TRWTF.
  • Tink (unregistered)

    It appears they forgot to account for leap seconds, which appear as second 60 or 61. On these (admittedly rare) occasions, users won't be able to connect…

  • Tink (unregistered) in reply to Tink

    Oh, ok, Chelloveck got there ahead of me: leap seconds are not supported in Java (Script?)

  • (cs) in reply to emaN ruoY
    emaN ruoY:
    Oh, come on people. We know the best way to solve this is with a math formula
    if (rslt1%3== 0) {domain1 = 'http://www.erightsoft.info';} else
    if (rslt1%3== 1) {domain1 = 'http://www.erightsoft.biz';} else
    if (rslt1%3== 2) {domain1 = 'http://www.erightsoft.org';}

    Granted, we lose the "randomness" achieved by alternating the order of the servers between the three line sections. But, really, that's just "overkill." If we want random, I suppose this may work:

    rslt1=Math.ceil(Math.random()*rslt1);
    if (rslt1%3== 0) {domain1 = 'http://www.erightsoft.info';} else
    if (rslt1%3== 1) {domain1 = 'http://www.erightsoft.biz';} else
    if (rslt1%3== 2) {domain1 = 'http://www.erightsoft.org';}

    And if you happen to generate a float from your Random call, you'll never ever get any domain at all. Or was that a hidden WTF inside your WTF?

  • Fri (unregistered) in reply to cellocgw
    emaN ruoY:
    Oh, come on people. We know the best way to solve this is with a math formula
    if (rslt1%3== 0) {domain1 = 'http://www.erightsoft.info';} else
    if (rslt1%3== 1) {domain1 = 'http://www.erightsoft.biz';} else
    if (rslt1%3== 2) {domain1 = 'http://www.erightsoft.org';}

    Granted, we lose the "randomness" achieved by alternating the order of the servers between the three line sections. But, really, that's just "overkill." If we want random, I suppose this may work:

    rslt1=Math.ceil(Math.random()*rslt1);
    if (rslt1%3== 0) {domain1 = 'http://www.erightsoft.info';} else
    if (rslt1%3== 1) {domain1 = 'http://www.erightsoft.biz';} else
    if (rslt1%3== 2) {domain1 = 'http://www.erightsoft.org';}

    This is a little shorter anyway: domain1 = "http://"+(rslt1%4?"www.erightsoft."+["info","biz","org"][rslt1%3]:"erightsoft.podzone.net")

  • Falc (unregistered) in reply to emaN ruoY

    You failed to notice they have 4 different servers. The 'alternating' servers is just because they put an empty line every 3 seconds instead of 4 fore some reason...

  • Dan Mercer (unregistered)

    This has the look of code that is adhoc and has been auto-generated, which would also cover the case where a server is offline - you would just generate a different list.

    captcha letatio - get your minds out of the gutter - it's Latin for "rejoicing".

  • Paul Neumann (unregistered) in reply to dkf
    dkf:
    faoileag:
    Actually, aren't you braking their EULA by posting it on TDWTF's website?
    I didn't know the EULA was equipped with brakes in the first place. What's the mean airspeed of an unladen EULA?
    It's approaching the speed of lint!
  • Paul Neumann (unregistered) in reply to dkf
    dkf:
    faoileag:
    Actually, aren't you braking their EULA by posting it on TDWTF's website?
    I didn't know the EULA was equipped with brakes in the first place. What's the mean airspeed of an unladen EULA?
    Or "moving at the speed of business"
  • foo AKA fooo (unregistered) in reply to Mike
    Mike:
    Is it elegant> No Does it work? Probably Is there a problem? Probably not It is a wtf? No
    Does the author know what a split second is? No Is this a WTF? Your pick ...
  • foo AKA fooo (unregistered) in reply to MB
    MB:
    A real load balancer just sends your request to a working server and marks the node down until it starts working again.
    <font color="RED" size="+10"><blink>If your download doesn't start within 5 seconds, please click on reload!1!</blink>

    Fixed?

  • (cs) in reply to faoileag
    faoileag:
    dkf:
    faoileag:
    Actually, aren't you braking their EULA by posting it on TDWTF's website?
    I didn't know the EULA was equipped with brakes in the first place. What's the mean airspeed of an unladen EULA?
    The missing "e" must have been posted to a different forum by my homegrown keystroke balancer...

    Move your coffee cup.

  • (cs) in reply to A Guy
    A Guy:
    Walky_one:

    if (a = 0) UseServer1; else if (a = 1) UseServer1; else if (a = 2) UseServer1; else if (a = 3) UseServer1; else if (a = 4) UseServer1; else if (a = 5) UseServer1; else if (a = 6) UseServer1; else if (a = 7) UseServer1; else if (a = 8) UseServer1; else if (a = 9) UseServer1; else if (a = 10) UseServer2; else if (a = 11) UseServer2; else if (a = 12) UseServer2; else if (a = 13) UseServer2; else if (a = 14) UseServer2; else if (a = 15) UseServer2; else if (a = 16) UseServer2; else if (a = 17) UseServer2; else if (a = 18) UseServer2; else if (a = 19) UseServer2; else UseServer3;

    This works too... I still would qualify it as a WTF.

    odd definition of 'works': always going for Server1

    (or are the '=' just 20 typos?)

    I was assuming pseudocode.

  • emaN ruoY (unregistered) in reply to cellocgw
    cellocgw:
    And if you happen to generate a float from your Random call, you'll never ever get any domain at all. Or was that a hidden WTF inside your WTF?

    According to w3schools, Math.ceil() returns an integer.

    (And, obviously, I'm not suggesting this as a real solution. :) )

  • (cs)

    Speaking of pseudocode, here's the funny way to do it, although the math is all wrong, but you get the idea:

    var URLs = { "http://www.erightsoft.info", "http://www.erightsoft.biz", "http://www.erightsoft.org" };

    var URLtoUse = URLs[currentSecond % URLs.length];

    You can add/remove URLs to the array easily, and the last line will work without updating it.

    if it even works at all

  • Andrew (unregistered)

    Give how painful it is to use Super® and the eRightSoft website it's not surprising that there are major WTFs to found in them.

  • Drone (unregistered) in reply to Mark Bowytz

    "Some of these third party companies... may even download and install several other softwares or toolbars"

    NSA... is that you?

  • (cs) in reply to Jeremy

    The problem comes when (for example) someone decides to rename a server (or get a different domain). A real load balancer would simply redistribute the load across the remaining servers. A simple redirect would just fail to serve the page, and therefore let people know what the problem is.

    This thing would work intermittently and be a giant pain in the ass to diagnose. Because every time the dev goes to look into it, it would hit the right second and work, but ever time the user tries to access, it would hit the wrong second and break.

  • Bryan (unregistered)

    This isn't actually a load balancer, but a mirror manager. It's not a WTF since I doubt they have THAT much load to balance. Instead it's a simple albeit messy way to handle a number of mirrors.

    Captcha: abigo This WTF wasn't abigo ne.

  • Kasper (unregistered) in reply to Gechurch
    Gechurch:
    Although your code is much cleaner, it does defeat the purpose as it will send all requests to one server for a 20 second period, which the other servers sit idle.
    In the original code it is not a 20 second period, but rather a 1 second period. Whether it is 1 second or 20 seconds, it is a WTF either way.

    It still does not balance the load, it just rotates all of the load through the servers every four seconds, and hopefully each server recovers before getting hit with the next burst of requests.

  • holysheet (unregistered) in reply to dkf
    dkf:
    faoileag:
    Actually, aren't you braking their EULA by posting it on TDWTF's website?
    I didn't know the EULA was equipped with brakes in the first place. What's the mean airspeed of an unladen EULA?
    Actually I think that EULA is FULLY laden. And if it crashed it would leave a long brown smear.
  • SunTzuWarmaster (unregistered) in reply to Mark Bowytz
    Mark Bowytz:
    Oh, one more thing - the download page encourages you with *pulsing pink text* to read the EULA before installing. A sentiment I happen to agree with in all cases, pulsing text or not.

    I didn't see it posted on their site, so I copied the EULA from the installer and posted it here for your reading pleasure: https://thedailywtf.com/images/14/Super_EULA.rtf

    Now, I don't encourage you to do as I did and download the installer just to read the EULA, but I do suggest that you check out the section marked "Privacy" to see why.

    You missed the best part!

    Un Installing When you UnInstall SUPER © from your PC machine, you wipe out the files related to the application itself. However, some or all of the third party companies recommendations softwares or toolbars may still be installed on your PC machine. UnInstalling SUPER © from your PC machine does not remove the related registry modifications applied to your PC machine during the installation. Each recommendations software has to be uninstalled separately through the "Configuration Panel". eRightSoft does not have any information about the recommended softwares and toolbars offered by the third party companies, therefore eRightSoft cannot provide any technical support or help on how to remove or un-install those recommended softwares and toolbars offered by the third party sponsor companies.

    That's right folks... When you uninstall, it won't uninstall everything, will leave stuff in your registry, and we won't tell you how to get rid of it. Right there in black and white: "eRightSoft cannot provide any technical support or help on how to remove or un-install those recommended softwares and toolbars offered by the third party sponsor companies"

  • (cs) in reply to SunTzuWarmaster
    SunTzuWarmaster:
    That's right folks... When you uninstall, it won't uninstall everything, will leave stuff in your registry, and we won't tell you how to get rid of it. Right there in black and white: "eRightSoft cannot provide any technical support or help on how to remove or un-install those recommended softwares and toolbars offered by the third party sponsor companies"

    Isn't that par for the course these days?

  • Bebert (unregistered) in reply to emaN ruoY

    WTF, no array?

  • ¯\(°_o)/¯ I DUNNO LOL (unregistered) in reply to Red Five
    Red Five:
    If they were just doing a time-based round-robin rotation, they didn't need to specify the server for each second. Just stick the servers into a numerically-indexed array in the desired order. Then do something like
    request_server = servers_array[seconds modulus count(servers_array)];
    Save about 60 lines of code that way, and it's exceedingly simple to add or remove servers and not have to change anything else.
    To the kind of people who write code like this, arrays are at the limit of their comprehension. The idea of an array of constants could break their brains.

    And there's no MOD button on any calculator they've ever seen, so they have no idea that exists either.

  • ¯\(°_o)/¯ I DUNNO LOL (unregistered) in reply to Walky_one
    Walky_one:
    Typos... I'm currently in "Delphi" mode (which uses single "=" for equal testing and ":=" for assignment). When switching to C++ / C# / Java (and back again) it's always the same issues...
    Try switching between Pascal and PL/I. That happened to me for a semester or two in college. (Yeah, that was a while ago.) No == to worry about, but the start of a function is almost exactly backwards.
  • Daniel Heath (unregistered) in reply to emaN ruoY

    This... actually makes a reasonable amount of sense for a whole range of use cases.

  • Daniel Heath (unregistered) in reply to Daniel Heath

    At least, it would if it worked.

  • (cs) in reply to ¯\(°_o)/¯ I DUNNO LOL
    ¯\(°_o)/¯ I DUNNO LOL:
    And there's no MOD button on any calculator they've ever seen, so they have no idea that exists either.

    That would actually be a great interview lead off question.

    "Do you have the slightest idea what modulus is, and what it can be used for?" "Uhhh......." "And we're done here."

  • AN AWESOME CODER (unregistered)

    Bad load balancer? Absolutely.

    But this is just about as much "load balancing" as SourceForge having multiple mirrors is.

    OH THE HORROR.

  • (cs) in reply to Jeremy
    Jeremy:
    That said, I'm not sure I get this "you either go 100% to a real load balancer or it's 100% useless" attitude. This still spreads some of the load around. Yes, if a server goes offline 1/3 of the people are SOL, but is that any worse than 100% of the people if the one server goes away?
    It's actually only 1/4 of the people because there are four servers, and even then they're not SOL because there's a 3 in 4 chance that just hitting Refresh will get them there anyway. So yeah, it's shitty code implementing fairly shitty load balancing, but it's better than nothing.
  • Cthon98 (unregistered) in reply to cellocgw
    cellocgw:
    emaN ruoY:
    Oh, come on people. We know the best way to solve this is with a math formula
    if (rslt1%3== 0) {domain1 = 'http://www.erightsoft.info';} else
    if (rslt1%3== 1) {domain1 = 'http://www.erightsoft.biz';} else
    if (rslt1%3== 2) {domain1 = 'http://www.erightsoft.org';}

    Granted, we lose the "randomness" achieved by alternating the order of the servers between the three line sections. But, really, that's just "overkill." If we want random, I suppose this may work:

    rslt1=Math.ceil(Math.random()*rslt1);
    if (rslt1%3== 0) {domain1 = 'http://www.erightsoft.info';} else
    if (rslt1%3== 1) {domain1 = 'http://www.erightsoft.biz';} else
    if (rslt1%3== 2) {domain1 = 'http://www.erightsoft.org';}

    And if you happen to generate a float from your Random call, you'll never ever get any domain at all. Or was that a hidden WTF inside your WTF?

    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/ceil

    The Math.ceil() function returns the smallest integer greater than or equal to a number.

    Or is it a WTF you don't know how rounding works?

    CAPTCHA: abbas - I like to listen to all types of abbas

  • (cs)

    Does anyone remember when SUPER wasn't crap? We had it on all our video machines when I was in school, and it handled files that nothing else would.

  • Norman Diamond (unregistered) in reply to faoileag
    faoileag:
    Walky_one:
    Mike:
    Is it elegant> No Does it work? Probably Is there a problem? Probably not It is a wtf? No
    if (a = 0) UseServer1; else if (a = 1) UseServer1; else if (a = 2) UseServer1; else if (a = 3) UseServer1; else if (a = 4) UseServer1; else if (a = 5) UseServer1; else if (a = 6) UseServer1; else if (a = 7) UseServer1; else if (a = 8) UseServer1; else if (a = 9) UseServer1; else if (a = 10) UseServer2; else if (a = 11) UseServer2; else if (a = 12) UseServer2; else if (a = 13) UseServer2; else if (a = 14) UseServer2; else if (a = 15) UseServer2; else if (a = 16) UseServer2; else if (a = 17) UseServer2; else if (a = 18) UseServer2; else if (a = 19) UseServer2; else UseServer3;

    This works too... I still would qualify it as a WTF.

    Exactly.

    You have three choices evenly distributed over 60 trigger integers? Use modulus.

    And Walky_one's solution is a wtf because it would be better written as

    if (a < 10) UseServer1;
    else if (a < 20) UseServer2;
    else UseServer3;
    
    And that's apart from the WTF of implementing a load balancer in JavaScript. That just balances the load of the AJAX requests but not the load of the page requests.
    No, your code is different from Walky's code. Walky might be depending on a having value 1 after the if statement, but you leave a undefined. Also your code might hit a less reliable server than the 1 he always hits.
  • Norman Diamond (unregistered) in reply to faoileag
    faoileag:
    JW:
    The real WTF is in this sentence: "...what I consider a rather unique approach..."

    "Unique" is an absolute. Being "rather unique" is like a boolean being "rather false".

    What's wrong with "rather false"?

    According to "Advanced Techniques in Knowledge Discovery and Data Mining" by Nikhil Pal (p. 187), "rather false" is one of seven states of truth, starting with "very true" and ending with "very false".

    That sounds like a rather unique book. Maybe only 1.3 copies exist, and you have 1 of them.

  • Anachronda (unregistered) in reply to Peter Wolff
    Peter Wolff:
    (They even use "umount" instead of "unmount", just to save 1 keystroke. Of course this isn't a WTF, is it?)

    I believe the use of "umount" vs "unmount" is more due to being limited to 6-character global names than the desire to save a character.

    I don't know that early Unix was limited to 6-character externals, but that was a popular limitation at the time.

  • Norman Diamond (unregistered) in reply to Chelloveck
    Chelloveck:
    I was about to make the observation that the code fails during a leap second, but a bit of Googling shows that the JS Date() object disavows all knowledge of leap seconds.
    So if a programmer uses the JS Date() object to query the present time and the present time happens to be a leap second, the JS Date() object falls over dead? So when programmers refuse to use the JS Date() API and roll their own WTFs instead, they're actually doing the right thing?
  • AnonymouseTheMany (unregistered)
    Some of these third party companies may recommend or provide advertisements about various services or may even download and install several other softwares or toolbars that replace your current browser's homepage and modify your default browser's search engine.

    Is that you, sourceforge?

  • SG_01 (unregistered)

    I believe most of that EULA is actually against the law in Europe, and they can definitely be sued for installing harmful software onto your computer ^^

  • S (unregistered) in reply to Kabi
    Kabi:
    I was rather disappointed that these URLs really point to different IP addresses. Based on this code, I expected that the requests for these adresses are all handled by the same server again...

    Hey, they could all resolve to the same IP - which was the address of a real load balancer... :)

  • nobulate (unregistered)

    Why load balance a site that hardly justifies a piece-of-shit software, it is not like they will get any visitors.

    ... oh wait. Never mind.

  • Hasse de great (unregistered) in reply to SG_01
    SG_01:
    I believe most of that EULA is actually against the law in Europe, and they can definitely be sued for installing harmful software onto your computer ^^

    This might only apply if the server you install from is located in an European country jurisdiction.

  • kirb (unregistered)
































































































































































































































































    view-source:www.erightsoft.info
  • nobulate (unregistered)

    Come to think of it, the probability of hitting any given second client-side equals hitting it with Math.floor(Math.random() * url_array.length)

    Mwhua hua hua hua. Ahem.

  • Flying Dutchman (unregistered) in reply to MB
    MB:
    Mike:
    Is it elegant> No Does it work? Probably Is there a problem? Probably not It is a wtf? No

    Statistically the load will be pretty much balanced probably.

    Not quite. TRWTF is that this won't usefully divide the work. The switch is based on the current time, so all requests arriving at the same time will go to the same server and not be spread out. So 3/4 of the severs are idle at any one time, negating any benefits having a load balancer.

  • Olo (unregistered) in reply to emaN ruoY

    Did you notice that "3" that you use for the modulo operation is actually the count of items?

    You could just put all URLs in an array and use "modulo arrayLenth" to index into that array:

    balancedUrls = ['http://www.erightsoft.info', 'http://www.erightsoft.biz', 'http://www.erightsoft.org'];
    
    domain1 = balancedUrls[rslt1 % balancedUrls.length];
    

    The bonus is that you can add more items to the array and it all works magically, you don't have to change anything else in the code.

Leave a comment on “Split Second Load Balancing”

Log In or post as a guest

Replying to comment #:

« Return to Article