I am me. Other people are not me. Some of those are me also. Life is complicated.
5 stories
·
4 followers

This Was Not Supposed to Be a Haunted Hayride by Django Gold

1 Share

Attention, passengers! I need you all to listen to me right now! Put down your souvenir Smallwood Farms cider mugs and pay attention. There can’t be any uncertainty surrounding what I’m about to say to you: This is not a haunted hayride, and the horrific events of the last 15 minutes were not planned or scripted in any way.

Truly, none of the madness that you have witnessed today was intended as part of our Fall Fun Time Hayride. Not the strands of animal entrails decorating this remote stretch of forest, not the sinister laughter echoing around us, and most crucially, not the berserk individuals who have been raiding our hayride wagon. Actually, it would in fact appear that these maniacs wish us very real harm.

This isn’t a joke. We are all in terrible danger.

Yes, I understand that Spooky Acres, Fright Forest, and various other attractions in the area operate haunted hayrides during the Halloween season, but please take my word that this is not one of them. Our hayride is a family-friendly excursion consisting of hot apple cider, group sing-a-longs, and some of the most beautiful autumn foliage upstate New York has to offer. It does not involve a swarm of deranged men flitting through the trees around us and shouting horrible threats while gleefully mutilating themselves with broken bottles.

Those men are not Smallwood Farms employees.

I wish you had listened. But when I first aired my concerns after seeing that the wooden bridge leading back to Smallwood Headquarters had mysteriously collapsed, leaving us to follow the direction offered by that crudely fashioned detour sign, it was clear from your “knowing” chuckles that you believed this to be part of a rehearsed performance. Similarly, you cheerfully ogled the increasingly appalling warning signs: the occult symbols carved into the surrounding tree trunks, that gruesome altar, the large piece of plywood with GO HOME FEDS scrawled on it in glaring red letters. The evidence strongly indicated that we had wandered into some sort of depraved backwoods murder haven—cause for alarm, not something for you to eagerly Instagram.

That pile of human heads was almost certainly real.

Still, you couldn’t stop “oohing” and “aahing,” even when the first wave of gibbering lunatics mounted our wagon and set upon our driver, slicing his throat from ear to ear as he begged for mercy. Let me assure you right now that none of that was “special effects.” There are no special effects. This is a cart being pulled by a tractor, and Patrick is dead, god damn you, his body dragged off into the woods for some kind of unimaginable desecration while you all applauded like fools.

And not to belabor the point, but I would think that the frantic nature of my own confrontation with that machete-wielding behemoth as he and I desperately wrestled for control of his blade would have suggested the profoundly dire nature of this hayride, particularly that part in the fight where I upended our tureen of scalding hot apple cider onto his deformed face while screaming, “Die, you son of a bitch! Die!” Rest assured that I did not mean any of that in a fun or “spooky” way.

Nonetheless, casting blame is not a luxury we have at our disposal at the moment. This wild pack of hillbilly psychotics knows that we’re on the run—yes, they’ve got a taste for it now. And once they regroup and take another pass at us, we’ll have two options: fight them off, or join them in the dark heart of the woods as unwilling participants in some Satanic rite that the civilized mind cannot comprehend. That is the choice as it stands before you on this grim Smallwood Farms afternoon.

Oh, I can hear them now. Scrambling through the woods, moaning and slavering like something out of a fever dream. They’ll be here soon, and when they arrive, I say beat them back with your fists, with your souvenir mugs, tear the planks from our besieged caravan and bludgeon these savages back into the darkest corridors of Hell. Do this, and you may yet return to a world in which the monsters are imagined and true evil but a gray shadow skulking in the woods. Kill them! Kill them. Can you freaks hear me out there? I hope that you can. Happy Halloween, you diseased maniacs!

Read the whole story
aquarion
4056 days ago
reply
London, United Kingdom
Share this story
Delete

Atomic deploys at Etsy

1 Share

A key part of Continuous Integration is being able to deploy quickly, safely and with minimal impact to production traffic. Sites use various deploy automation tools like Capistrano, Fabric and a large number of homegrown rsync-based ones. At Etsy we use a tool we built and open-sourced called Deployinator.

What all these tools have in common is that they get files onto multiple servers and are able to run commands on those servers. What ends up varying a lot is what those commands are. Do you clear your caches, graceful your web server, prime your caches, or even stagger your deploys to groups of servers at a time and remove them from your load balancer while they are being updated? There are good reasons to do all of those things, but the less you have to do, the better. It should be possible to atomically update a running server without restarting it and without clearing any caches.

The problem with deploying new code to a running server is quite simple to understand. A request that starts on one version of the code might access other files during the request and if those files are updated to a new version during the request you end up with strange side effects. For example, in PHP you might autoload files on demand when instantiating objects and if the code has changed mid-request the caller and the implementation could easily get out of synch. At Etsy, it was quite normal to have to split significant code changes over 3 deploys before implementing atomic deploys. One deploy to push the new files. A second deploy to push the changes to make use of the new code and a final deploy to clean up any outdated code that isn’t needed anymore.

The problem is simple enough, and the solution is actually quite simple as well. We just need to make sure that we can run concurrent requests on two versions of our code. While the problem statement is simple, actually making it possible to run different versions of the code concurrently isn’t necessarily easy.

When trying to address this problem in the past, I’ve made use of PHP’s realpath cache and APC (a PHP opcode cache, which uses inodes as keys). During a deploy the realpath cache retains the inodes from the previous version, and the opcode cache would retain the actual code from the previous version. This means that requests that are currently in progress during a deploy can continue to use the previous version’s code as they finish. WePloy is an implementation of this approach which works quite well.

With PHP 5.5 there is a new opcode cache called Opcache (which is also available for PHP 5.2-5.4). This cache is not inode-based. It uses realpaths as the cache keys, so the inode trick isn’t going to work anymore. Relying on getting the inodes from a cache also isn’t a terribly robust way of handling the problem because there are still a couple of tiny race windows related to new processes with empty caches starting up at exactly the wrong time. It is also too PHP-oriented in that it relies on very specific PHP behaviour.

Instead of relying on PHP-specific caching, we took a new look at this problem and decided to push the main responsibility to the web server itself. The base characteristic of any atomic deploy mechanism is that existing requests need to continue executing as if nothing has changed. The new code should only be visible to new requests. In order to accomplish this in a generic manner we need two document roots that we toggle between and a new request needs to know which docroot it should use. We wrote a simple Apache module that calls realpath() on the configured document root. This allows us to make the document root a symlink which we can toggle between two directories. The Apache module sets the document root to this resolved path for the request so even if a deploy happens in the middle of the request and the symlink is changed to point at another directory the current request will not be affected. This avoids any tricky signaling or IPC mechanisms someone might otherwise use to inform the web server that it should switch its document root. Such mechanisms are also not request-aware so a server with multiple virtual hosts would really complicate such methods. By simply communicating the docroot change to Apache via a symlink swap we simplify this and also fit right into how existing deploy tools tend to work.

We called this new Apache module mod_realdoc.

If you look at the code closely you will see that we are hooking into Apache first thing in the post_read_request hook. This is run as soon as Apache is finished reading the request from the client. So, from this point on in the request, the document root will be set to the target of the symlink and not the symlink itself. Another thing you will notice is that the result of the realpath() is cached. You can control the stat frequency with the RealpathEvery Apache configuration directive. We have it set to 2s here.

Note that since we have two separate docroots and our opcode cache is realpath-based, we have to have enough space for two complete copies of our site in the cache. By having two docroots and alternating between them on successive deploys we reuse entries that haven’t changed across two deploys and avoid “thundering herd” cache issues on normal deploys.

If you understand things so far and have managed to compile and install mod_realdoc you should be able to simply deploy to a second directory and when the directory is fully populated just flip the docroot symlink to point to it. Don’t forget to flip the symlink atomically by creating a temporary one and renaming it with “mv -T“. Your deploys will now be atomic for simple PHP, CGI, static files and any other technology that makes use of the docroot as provided by Apache.

However, you will likely have a bit more work to do for more complex scenarios. You need to make sure that nothing during your request uses the absolute path to the document_root symlink. For example, if you configure Apache’s DOCUMENT_ROOT for your site to be /var/www/site/htdocs and then you have /var/www/site be a symlink to alternatingly /var/www/A and /var/www/B you need to check your code for any hardcoded instances of /var/www/site/htdocs. This includes your PHP include_path setting. One way of doing this is to set your include_path as the very first thing you do if you have a front controller in your application. You can use something like this:

ini_set('include_path', $_SERVER['DOCUMENT_ROOT'].'/../include');

That means once mod_realdoc has resolved /var/www/site/htdocs to /var/www/A/htdocs your include_path will be /var/www/A/htdocs/../include for the remainder of this PHP request and even if the symlink is switched to /var/www/B halfway through the request it won’t be visible to this request.

At Etsy we don’t actually have a front controller where we could easily make this app-level ini_set() call, so we wrote a little PHP extension to do it for us. It is called incpath.

This extension is quite simple. It has three ini settings. incpath.docroot_sapi_list specifies which SAPIs should get the docroot from the SAPI itself. incpath.realpath_sapi_list lists the SAPIs which should do the realpath() call natively. When the extension does the realpath() itself it is essentially a PHP version of the mod_realpath module resolving the symlink in the extension itself. And finally, incpath.search_replace_pattern specifies the string to replace in the existing include_path. It is easier to understand with an example. At Etsy we have it configured something like this:

incpath.docroot_sapi_list = apache2handler
incpath.realpath_sapi_list = cli
incpath.search_replace_pattern = /var/www/site/htdocs

This means that when running PHP under Apache we will get the document root from Apache (apache2handler) and we will look for “/var/www/site/htdocs” in the include_path and replace it with the document root we got from Apache. For cli we will do the realpath() in the extension and use that to substitute into the include_path. Our PHP configuration then has the include_path set to:

/var/www/site/htdocs/../include:.

which the incpath extension will modify to be either /var/www/A/htdocs/../include or /var/www/B/htdocs/../include.

This include_path substitution is done in the RINIT PHP request hook which runs at the beginning of every request before any PHP code has run. The original include_path is restored at the end of the request in the RSHUTDOWN PHP hook. You can, of course, specify different search_replace_pattern values for different virtual hosts and everything should work fine. You can also skip this extension entirely and do it at the app-level or even through PHP’s auto_prepend functionality.

Some caveats. First and foremost this is about getting atomicity for a single web request. This will not address multi-request atomicity issues. For example, if you have a request that triggers AJAX requests back to the server, the initial request and the AJAX request may be handled by different versions of the code. It also doesn’t address changes to shared resources. If you change your database schema in some incompatible way such that the current and the new version of the code cannot run concurrently then this won’t help you. Any shared resources need to stay compatible across your deploy versions. For static assets this means you need proper asset versioning to guarantee that you aren’t accessing incompatible js/css/images.

If you are currently using Apache and a symlink-swapping deploy tool like Capistrano, then mod_realdoc should come in handy for you, and it is likely to let you remove a graceful restart from your deploy procedure. For non-Apache, like nginx, it shouldn’t be all that tricky to write a similar plugin which does the realpath() call and fixates the document root at the top of a request insulating that request from a mid-request symlink change. If you use this Apache module or write your own for another server, please let us know in the comments.


Read the whole story
aquarion
4176 days ago
reply
London, United Kingdom
Share this story
Delete

Updates to the Newspeak Dictionary, 2013 by Michael Levy

2 Shares

lifedoc – The practice of taking time out of an ostensibly enjoyable activity for the purpose of documenting that activity.

“That guy’s gotta quit it with the lifedoc. Put the phone down, buddy.”

- -

waitsend – The act of delaying one’s response to a text message so as to avoid creating an expectation for an immediate response.

“Hmm, this seems fun, I’ll waitsend and then let her know we’re gonna be there.”

- -

waitlike – Similar to waitsend in that it is an intentional delay, but in this case it refers to seeing the moment when a social media post is created. It is the act of waiting a given amount of time before reacting to the post to create the illusion that one arrived at the social media site after engaging in other meaningful activities.

“Yeah, this photo’s hilarious, I gotta waitlike for a minute though, then I’ll give it a LOL.”

- -

tweetthink – The impulse you have, after naturally saying something funny in conversation, to craft that statement into a social media post.

“[heheh, that really got a laugh, I wonder how I wou— no, damn it, this is tweetthink again]”

- -

talkstop – A moment during a meal between two people when they both acknowledge, silently or vocally, that they would like to pause their conversation and check their phones for updates and reply to any missed messages.

“Look at the couple over there, that talkstop has been going on for a while.”

- -

quickknow – The slight pause in an instant message conversation while one person looks up the definition to something that the other person said.

“Shoot, I hope he didn’t notice that quickknow while I looked up ‘sconce.’”

- -

conbreak – The act of going to the bathroom during a social event, not to actually use the bathroom, but to check one’s phone.

“He’s been in the bathroom for a while, I’m pretty sure he’s on a conbreak.”

- -

voidshout – The disappointment one feels after a photo or status update that one thought was funny or important, doesn’t get any response.

“I really thought people would like this photo of my baby but I guess it’s just more voidshout.”

- -

untweet – The practice of removing an social media post at a later date once that post becomes embarrassing.

“Yeah, that photo’s great, but you better save it, she’ll probably untweet it.”

Read the whole story
aquarion
4210 days ago
reply
London, United Kingdom
Share this story
Delete

Hoodie: very fast web app development

1 Share
Comments
Read the whole story
aquarion
4261 days ago
reply
London, United Kingdom
Share this story
Delete

Planes, An Upcoming 3D Animated Comedy Adventure by Disney

2 Comments and 3 Shares


Planes, An Upcoming 3D Animated Comedy Adventure by Disney

Read the whole story
aquarion
4264 days ago
reply
:-/
London, United Kingdom
Share this story
Delete
1 public comment
lillie
4265 days ago
reply
nooooooooooooooo
La Lengua, San Francisco
lillie
4265 days ago
travis' comment: "it's a long way off, maybe they'll forget to make it before then."
ryanbrazell
4265 days ago
i'm waiting for "horses and buggies"
mgeraci
4264 days ago
Trains.