📜 ⬆️ ⬇️

Sparkfun.com FREE day or * what do you think of recaptcha *

Inspiration

While 55% hate ...

And I chose the "other". Because I love. But not for what I consider more convenient than others, but for the fact that ...

Once a year, the American company sparkfun.com, well known to every DIY-ps, holds (almost) a lottery. For the last, or, as the parachutists say, the last time they did it was January 10th of this year. The essence is simple - you go to the site and within a certain time you solve those same hated recaptchas. Some device randomly chooses one of the guessed captcha and gives the author a certificate for $ 100 - with this money you can order anything on sparkfan, only delivery is paid. That is absolutely honest giv-evay.
')
And so, in the 9th Colorado time, a lot of people from all over the world sit down to guess the recaptcha. The site immediately falls. A stub is placed in its place, which apologizes for the inaccessibility of the store and throws you onto a separate page to solve the captchas. In fact, there, in Colorado, people do not sit and do not laugh at razgadyvalschikami, and struggles to overcome this habraeffekt.

I won - after half an hour driving in the recaptcha:



Imagine how many people have already thrown to read and shit in my karma. Now delicious for the most persistent. Translation of the report from the sparkfan site:

Free day report


January 12, 2012


Again, January and another Free Day. Whether you won or lost, we hope everyone enjoyed it. Oh, we got a ton of pleasure in arranging it - that's for sure!

Numbers:
Some numbers, then I will tell you how we organized it.

More numbers for those in the subject.






The actual installation that was used


As we did this - again, for geeks. If you participated in the first two promotions, you might have noticed that the promotion went much better this year. If we exclude the fact that the site choked in the first minutes, when the largest influx of participants went, the site responded to itself quite well, while it actually handled huge traffic. What has changed compared to previous years?
We pulled some software and hard to our servers. Now we have a couple of fat web servers, each with 16 cores and 32 gigabytes of RAM, and we have hard-load load balancers.
Plus, we optimized our own code for working with our hardware, changed some open-source software. We also migrated from Apache to Nginx, where PHP-FPM handled all the processing. Before all this, Tarnish Varnish is still caching everything that comes out - which turned out to be awesome for the promotion.
Also, in past years, we noticed that most often lags were caused by MySQL brakes, well, we backed it in some places with MongoDB. For some (especially hierarchical data) this made sense. This helped us really quickly show the page. Unfortunately, because of a small bug in the PHP Mongo driver, we got a gag in the first minutes of the action.
Previously, we all gave all the content directly from our server. When the load is normal, this is OK - the pages load normally and the channel we eat is small. Naturally, during the Free Day, everything changes. This year we have all the static content hung on the Amazon Cloudfront. Cloudfront is such a global CDN that sits on top of the well-known S3 store and loads content from regional servers to users all over the world. In this case, of course, the burden falls on them, not on us. But this does not save much either. Those 76Mb / s, which we passed through our servers - it was basically gzip-packed text.

Geiger counter?



Well, what. Anyone familiar with computer science will tell you that the random numbers that the computer generates are actually pseudo-random numbers. They can be predicted - even if there is 1 chance out of a million in success, it is still a chance. So how do we build an absolutely random system?
We chose a geiger counter to measure background radiation. The counter pulls the controller's foot down each time it sees a charged particle - it happens absolutely exactly at random. We installed our Ethernet Pro to monitor these interruptions and send a byte to the daemon sitting on one of the web servers, so that it would notify the next guessed captcha about the victory.

Here is the code for dunya:

#include <Ethernet.h> #include <SFEbarGraph.h> #include <SPI.h> // Default 'ino MAC address byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; byte ip[] = { 192, 168, 0, 2 }; int up = 8; int down = 7; int upstate = 0; int downstate = 0; // replace with your server byte server[] = { 192, 168, 0, 1 }; EthernetClient client; SFEbarGraph BG; volatile int counter = 0; int oldcount = 0; int target = 8; int multiplier = 2; void setup() { BG.begin(1, 9); // Interrupt from the Geiger tube attachInterrupt(0, detect, RISING); Serial.begin(9600); Ethernet.begin(mac, ip); // set up buttons pinMode(up, INPUT); digitalWrite(up, HIGH); pinMode(down, INPUT); digitalWrite(down, HIGH); delay(1000); } void loop() { // read up button if(LOW == digitalRead(up)) { if(0 == upstate) { target++; redraw(); upstate = 1; } } else { upstate = 0; } // read down button if(LOW == digitalRead(down)) { if(0 == downstate) { target--; redraw(); downstate = 1; } } else { downstate = 0; } if(counter == oldcount) { delay(1); return; } oldcount = counter; // handle wins if(counter >= target) { win(); counter = 0; oldcount = 0; return; } redraw(); } // for the interrupt void detect() { counter++; } void redraw() { // boundaries if(target > (30 / multiplier)) target = (30 / multiplier); if(target < 1) target = 1; BG.clear(); BG.send(); BG.barGraph(counter * multiplier, target * multiplier); } void win() { Serial.println("WINNER"); for(int i = target * multiplier; i >= 0; i--) { BG.barGraph(i, target * multiplier); delay(35); } if ( ! client.connected()) { Serial.println("connecting..."); if (client.connect(server, 5555)) { Serial.println("connected"); } else { Serial.println("connection failed"); } } // Print a 1 to the Ethernet server for every win client.print("1"); } 


Well, to close the topic, here's the bit server code that Ben wrote to handle hundreds of requests per second. He tested it on load up to 600 thousand requests per second.

Well, who knows English - do not deny yourself the pleasure of reading the comments on this post and watch the video . There you will find out if the people love captcha.



From the translator and the author of the post: the translation is quite free - do not judge. The mood is that either this way or that way.

Source: https://habr.com/ru/post/155161/


All Articles