Posts Tagged 'Speed'

December 8, 2011

UNIX Sysadmin Boot Camp: bash - Keyboard Shortcuts

On the support team, we're jumping in and out of shells constantly. At any time during my work day, I'll see at least four instances of PuTTY in my task bar, so one thing I learned quickly was that efficiency and accuracy in accessing ultimately make life easier for our customers and for us as well. Spending too much time rewriting paths, commands, VI navigation, and history cycling can really bring you to a crawl. So now that you have had some time to study bash and practice a little, I thought I'd share some of the keyboard shortcuts that help us work as effectively and as expediently as we do. I won't be able to cover all of the shortcuts, but these are the ones I use most:

Tab

[Tab] is one of the first keyboard shortcuts that most people learn, and it's ever-so-convenient. Let's say you just downloaded pckg54andahalf-5.2.17-v54-2-x86-686-Debian.tar.gz, but a quick listing of the directory shows you ALSO downloaded 5.1.11, 4.8.6 and 1.2.3 at some point in the past. What was that file name again? Fret not. You know you downloaded 5.2.something, so you just start with, say, pckg, and hit [Tab]. This autocompletes everything that it can match to a unique file name, so if there are no other files that start with "pckg," it will populate the whole file name (and this can occur at any point in a command).

In this case, we've got four different files that are similar:
pckg54andahalf-5.2.17-v54-2-x86-686-Debian.tar.gz pckg54andahalf-5.1.11-v54-2-x86-686-Debian.tar.gz
pckg54andahalf-4.8.6-v54-2-x86-686-Debian.tar.gz
pckg54andahalf-1.2.3-v54-2-x86-686-Debian.tar.gz

So typing "pckg" and hitting [Tab] brings up:
pckg54andahalf-

NOW, what you could do, knowing what files are there already, is type "5.2" and hit [Tab] again to fill out the rest. However, if you didn't know what the potential matches were, you could double-tap [Tab]. This displays all matching file names with that string.

Another fun fact: This trick also works in Windows. ;)

CTRL+R

[CTRL+R] is a very underrated shortcut in my humble opinion. When you've been working in the shell for untold hours parsing logs, moving files and editing configs, your bash history can get pretty immense. Often you'll come across a situation where you want to reproduce a command or series of commands that were run regarding a specific file or circumstance. You could type "history" and pore through the commands line by line, but I propose something more efficient: a reverse search.

Example: I've just hopped on my system and discovered that my SVN server isn't doing what it's supposed to. I want to take a look at any SVN related commands that were executed from bash, so I can make sure there were no errors. I'd simply hit [CTRL+R], which would pull up the following prompt:

(reverse-i-search)`':

Typing "s" at this point would immediately return the first command with the letter "s" in it in the history ... Keep in mind that's not just starting with s, it's containing an s. Finishing that out to "svn" brings up any command executed with those letters in that order. Pressing [CTRL+R] again at this point will cycle through the commands one by one.

In the search, I find the command that was run incorrectly ... There was a typo in it. I can edit the command within the search prompt before hitting enter and committing it to the command prompt. Pretty handy, right? This can quickly become one of your most used shortcuts.

CTRL+W & CTRL+Y

This pair of shortcuts is the one I find myself using the most. [CTRL+W] will basically take the word before your cursor and "cut" it, just like you would with [CTRL+X] in Windows if you highlighted a word. A "word" doesn't really describe what it cuts in bash, though ... It uses whitespace as a delimiter, so if you have an ultra long file path that you'll probably be using multiple times down the road, you can [CTRL+W] that sucker and keep it stowed away.

Example: I'm typing nano /etc/httpd/conf/httpd.conf (Related: The redundancy of this path always irked me just a little).
Before hitting [ENTER] I tap [CTRL+W], which chops that path right back out and stores it to memory. Because I want to run that command right now as well, I hit [CTRL+Y] to paste it back into the line. When I'm done with that and I'm out referencing other logs or doing work on other files and need to come back to it, I can simply type "nano " and hit [CTRL+Y] to go right back into that file.

CTRL+C

For the sake of covering most of my bases, I want to make sure that [CTRL+C] is covered. Not only is it useful, but it's absolutely essential for standard shell usage. This little shortcut performs the most invaluable act of killing whatever process you were running at that point. This can go for most anything, aside from the programs that have their own interfaces and kill commands (vi, nano, etc). If you start something, there's a pretty good chance you're going to want to stop it eventually.

I should be clear that this will terminate a process unless that process is otherwise instructed to trap [CTRL+C] and perform a different function. If you're compiling something or running a database command, generally you won't want to use this shortcut unless you know what you're doing. But, when it comes to everyday usage such as running a "top" and then quitting, it's essential.

Repeating a Command

There are four simple ways you can easily repeat a command with a keyboard shortcut, so I thought I'd run through them here before wrapping up:

  1. The [UP] arrow will display the previously executed command.
  2. [CTRL+P] will do the exact same thing as the [UP] arrow.
  3. Typing "!!" and hitting [Enter] will execute the previous command. Note that this actually runs it. The previous two options only display the command, giving you the option to hit [ENTER].
  4. Typing "!-1" will do the same thing as "!!", though I want to point out how it does this: When you type "history", you see a numbered list of commands executed in the past -1 being the most recent. What "!-1" does is instructs the shell to execute (!) the first item on the history (-1). This same concept can be applied for any command in the history at all ... This can be useful for scripting.

Start Practicing

What it really comes down to is finding what works for you and what suits your work style. There are a number of other shortcuts that are definitely worthwhile to take a look at. There are plenty of cheat sheets on the internet available to print out while you're learning, and I'd highly recommend checking them out. Trust me on this: You'll never regret honing your mastery of bash shortcuts, particularly once you've seen the lightning speed at which you start flying through the command line. The tedium goes away, and the shell becomes a much more friendly, dare I say inviting, place to be.

Quick reference for these shortcuts:

  • [TAB] - Autocomplete to furthest point in a unique matching file name or path.
  • [CTRL+R] - Reverse search through your bash history
  • [CTRL+W] - Cut one "word" back, or until whitespace encountered.
  • [CTRL+Y] - Paste a previously cut string
  • [CTRL+P] - Display previously run command
  • [UP] - Display previously run command

-Ryan

November 28, 2011

Brisket and BYOC

With all of the cooking and eating going on around Thanksgiving, Summer's Truffle Mac and Cheese blog inspired me to think back on any of the "expertise" I can provide for SoftLayer customers in the kitchen. One of the first things my mother taught me to cook was brisket. While it might not be as exotic as 3 Bars Barbeque, it's pretty easy to make. Everyone who tastes it sings its praises and thinks it took forever to prepare, and while it does have to cook in the oven for about four hours, there are only five ingredients, so the "preparation" time is actually only around ten minutes. Since it's not exactly a family secret, I don't think I'll get into any trouble for sharing it:

Easy-To-Make Brisket Ingredients

  • 1 Brisket - I'd recommend having the majority (not all) of the fat trimmed off at the store
  • 2 1/2 Cups of Ketchup - Buy the largest ketchup bottle and plan on using a little more than half
  • 1 1/2 Cups of Water
  • 1 Packet of Onion Soup Mix
  • 1 Can of Tomato Paste (Optional, adds flavor)

Instructions

  1. Pre-heat oven to 300 degrees
  2. Mix all of the non-brisket ingredients and pour them on top of the brisket in a large roaster (one with a lid would be preferable)
  3. Make sure the entire brisket is covered. Pick it up to get your other ingredients underneath.
  4. Pop it into the oven for four hours at 300 degrees.
  5. Take it out, let it cool, and enjoy!

That's the basic, original recipe, but I've found a few ways to make it juicier along the way. One tip is to pull the brisket from the oven after about three and a half hours and slice it against the grain. If you have an electric knife, this is the perfect chance to use it, and if you don't, this could be an excuse to get one. Put the brisket back in the roaster for another half hour, and you'll love the results. Because ovens differ, just make sure it's moist before you take it out to serve.

At this point, you're probably asking yourself what a brisket recipe has to do with SoftLayer. If you've used our Build Your Own Cloud wizard, you might already see the similarity: You can put something together that seems dauntingly time consuming quickly and without breaking a sweat ... And the end result is amazing. There are a few simple steps to making an impressive brisket, and it takes a few clicks to build a customized cloud instance with all the benefits of SoftLayer's global network and support.

Too often, selecting a cloud instance involves more limitations than it does choices, so we wanted to make sure the BYOC service enabled customers the granularity to choose CPU, RAM, and storage configurations on newer, more powerful servers than our competition. Just like my tweak of the original recipe, we want customers to have the ability to tweak their cloud platform to provide the best application performance, cost efficiency, and availability for their specific needs.

If this blog left you hungry, you've got everything you need to make an amazing brisket. If you don't have the ingredients (or the four hours) you need to make one now, you can try the quicker BYOC recipe:

SoftLayer Cloud Ordering Ingredients

  • The device you're using to read this blog.
  • A list of what you want on your cloud instance.

Instructions

  1. Visit SoftLayer's Build Your Own Cloud page.
  2. Select the options you want and submit your order.
  3. Start using your custom cloud instance in less than 20 minutes!

Happy Building! :-)

-Rachel

Categories: 
September 13, 2011

SoftLayer Features and Benefits - Automation

Features and benefits ... They're like husband and wife, horse and carriage, hammer and nails! They are inseparable and will always complement each other. I wanted to jump right into a key "features and benefits" analysis of one of the value propositions of the SoftLayer platform, but before I did, I want to make sure we are all on the same page about the difference between the two.

A feature is something prominent about a person, place or thing. It's usually something that stands out and makes whatever you're talking about stand out — for the purpose of this discussion it will be, at least. It could be something as simple as the new car you're buying having a front windshield or the house you're looking to buy having a garage. Maybe it's something a little more distinct like having your car's air conditioner stay cool and blow for 15 min after the ignition is switched to the ACC position when you turn your engine off while pumping gas. Maybe your house has a tank-less water heater. These examples are indeed real features, but the first two are more or less expected ... The last two make this particular car and this particular house stand out.

So where do the benefits come in? Benefits are features that are useful or profitable to you. With you being the operative word here. Think about it: If a feature does not provide any use to you, why would you care? Let's go back to the car with its unique A/C feature. What if you live in Greenland? Who cares that the A/C will stay on? You may not even care for the feature of having an air conditioner at all! Talk about that feature in Dallas, TX, where it has been over 100 degrees for the last 2 months and counting, and all of a sudden, this feature provides a real benefit!

It's now your cue to ask how all of this relates to hosting or, more specifically, SoftLayer.

{ ... Waiting for you to ask ... }

I am glad you asked! If you haven't noticed, SoftLayer boasts a wide array of features on our website, and I would like to point out some of the benefits that may not be apparent to everyone, starting with automation. You're probably aware that SoftLayer has one of the most robust and full featured automation platforms in the industry.

Automation

Think about the last time your IT director sent an email that went into your junk mail folder ... You happen to see it on Sunday night, and it reads, "Please stand up five test servers for a new project by the Monday morning meeting." You know that the vendors you typically use take anywhere from 3 days to 2 weeks to stand up new servers, so you wouldn't have had a problem if you saw the email a week ago when it was sent — but you didn't. So to avoid getting a smudge on your perfect employee record, you stumble across softlayer.com where automation enables us to deliver your five servers in 2 hours. Talk about a benefit: You still have time to watch a little TV before going to bed ... Five servers, to your exact specifications, all deployed before you could Google the orgin of "rubber baby buggy bumbers." (For those who care, it was a tag line said by Arnold Schwarzenegger in the movie Last Action Hero.)

At the heart of our automation platform lives the dedicated server, and the blood that courses though our network is the API. All that's left is the pretty face (which we call the Customer Portal). Our portal provides a graphical user interface to control every aspect of your account from ordering new servers, IP allocations and hardware reboots to port control, port speed selection and billing matters. If you're more into the behind-the-scenes stuff, then you can use all the same controls from the comfort of your own application via the API. Sounds like a lot of features to me, where are the benefits?

To start, you have options! Who doesn't like options? You get to choose how you want to manage your account and infrastructure. We don't force you into "our" way. Secondly, being able to do most functions yourself enables you to be more efficient. You know what you want, so you can log in and get it. No need to wait two hours for your firewall rule set to update; just log in and change it. You want to add load balancing to your account? Log in and order it! How about SAN replication? ... I think you see where I'm going with this. Our portal and automation bring this control to your computer anywhere in the world! Some of these features even extend to your iPhone and android platform. Now you can update your support tickets while at the park with the kids.

Look for a second installment of our study on SoftLayer Features and Benefits! There are many more features that I want to translate into benefits for you, so in the more familiar words of Arnold Schwarzenegger, "I'll be back"!

-Harold

August 28, 2008

The Speed of Light is Your Enemy

One of my favorite sites is highscalability.com. As someone with an engineering background, reading about the ways other people solve a variety of problems is really quite interesting.

A recent article talks about the impact of latency on web site viewers. It sounds like common sense that the slower a site is, the more viewers you lose, but what is amazing is that even a latency measured in milliseconds can cost a web site viewers.

The article focuses mainly on application specific solutions to latency, and briefly mentions how to deliver static content like images, videos, documents, etc. There are a couple ways to solve the static content delivery problem such as making your web server as efficient as you can. But that can only help so much. Physics - the speed of light - starts to be your enemy. If you are truly worried about shaving milliseconds off your content delivery time, you have to get your content closer to your viewers.

You can do this yourself by getting servers in datacenters in multiple sites in different geographic locations. This isn't the easiest solution for everyone but does have its advantages such as keeping you in absolute control of your content. The much easier option is to use a CDN (Content Delivery Network).

CDNs are getting more popular and the price is dropping rapidly. Akamai isn't the only game in town anymore and you don't have to pay dollars per GB of traffic or sign a contract with a large commit for a multi-year time frame. CDN traffic costs can be very competitive costing only a few pennies more per Gb compared with traffic costs from a shared or dedicated server. Plus, CDNs optimize their servers for delivering content quickly.

Just to throw some math into the discussion let's see how long it would take an electron to go from New York to San Francisco (4,125,910 meters / 299,792,458 meters per second = 13.7 milliseconds). 13.7 millisconds one way, now double that for the request to go there and the response to return. Now we are up to 27.4 milliseconds. And that is assuming a straight shot with no routers slowing things down. Let's look at Melbourne to London. (16,891,360 meters / 299,792,458 meters per second = 56.3 milliseconds). Now double that, throw in some router overhead and you can see that the delays are starting to be noticeable.

The moral of the story is that for most everybody, distributing static content geographically using a CDN is the right thing to do. That problem has been solved. The harder problem is how to get your application running as efficiently as possible. I'll leave that topic for another time.

-@nday91

May 14, 2008

On Site Development

I have a friend who worked at an internationally recognized fast food restaurant. It relies heavily on it’s computer systems to operate. Being a programmer (I’ve always preferred Computer Alchemist), I’ve always been fascinated with the command and control programs used at these restaurants, and have drilled many family members and friends to describe (in the most non-specific non-job-endangering way) what they do with those computers to do their job.

At the fast food restaurant, every order is entered into the cash register at the front of the line, processed by the computer systems on site, the orders are relayed to the kitchen in realtime and displayed on monitors, and various thermal ticket printers spit out meal tickets to be affixed to the various food items to describe their state (Double Cheeseburger, No Pickles, No Onions, Add Secret Sauce). It’s an amazing dance of software.

But I noticed that my friend the grill cook was constantly complaining about the system. Apparently, the order processing is really real time. When the guy up front presses the “double cheeseburger” button, it immediately lights up in the back but it doesn’t alert you that this is an order in progress! So, if the cooks are in a rush and just preparing orders as fast as possible, they might already have the pickles on the burger before the lady up front presses the “No Pickles” button, updating the display. Also, updated items are NOT IDENTIFIED by the system, so if the burger is already wrapped and the burger man is already moving to the next little square, it might not be caught! (Keep this in mind: most order “errors” at this internationally recognized fast food restaurant are caused by slow order takers, or slow customers, or customers who change their mind at the end of an order (Oh, could you make that burger with no onions?). Remember, if the guys in the back are rushing, get your order together in your head before you speak. If you say “Double Cheeseburger, no pickles, no onions, add secret sauce” just like that, it’ll pop into the system the right way!)

My question, of course, was “Why not rewrite the cash registers to be more awesome?” See, the old registers tied into a small computer in the back room that tied into the monitors in the kitchen. All state was held on that one machine, so obviously as soon as it was updated, it would appear on the monitors. But I couldn’t figure out why they kept using this stupid backwards system. It’s 2008! When I worked in the local greasepit in my small town, we used paper tickets we were more efficient than this fast food restaurant’s system! So why haven’t they updated? Simple: the people who can fix it aren’t there to use it.

Aha! That’s what makes SoftLayer so awesome. See, our programming staff is right here, in the same office as everyone else (except for those people who work in our datacenters, but they have our internal IM, email, and phone numbers and know they can contact us at any time.). If something breaks, or if something is built in a backwards or strange way, we know immediately and can turn around and fix it. In fact, we have a whole lot of programmers, as a ratio of developers to normal people. This high ratio allows us to have the best control portal in the world, and to add features quickly. See, if only developers worked at that fast food restaurant, and saw how the system was used, and were allowed to make changes (another awesome bit about SoftLayer: management is open to change. You’d be surprised how many obvious changes simply are not allowed by management in some dev shops…), then it would be a much easier place for everyone involved. And maybe I’d get my Double Cheeseburger right. Without the onions.

-Zoey

Categories: 
November 2, 2007

No-Huddle

With the NFL season in full swing and the usual suspects up to their usual tricks, a question was raised as to why some teams opt to run a "no-huddle" or "hurry-up" offense when their backs are against the wall with the clock ticking away, while other teams seem to constantly be in a "hurry-up" mode throughout the game and have a significant degree of success with it. In either case, the objective is to keep the competition off balance and have steady advances to the goal. An obvious example of an undeniably successful team that employs such methods is the reigning NFL Champion Indianapolis Colts.

Before I go further into lumping praise onto the Colts, I feel that I am obligated to state that I am not a die-hard Indy fan. The team that I root for shall remain nameless for this article as I am still traumatized by the hammer that they leveled on my team of choice on the NFL's opening night (Hint: Rhymes with "The Aints.").

Okay, so this observation invites the question: how did the Colts become champions by performing in a manner that, to outsiders, may appear to be rushed and distressed? One could say it's because they have trusted, senior individuals in their skill positions implementing the plan. Another might say that by focusing on rapid incremental results, they are able to execute more efficiently. An additional point might be that the constant communication amongst the players allows them to adapt to the circumstances that are constantly changing so that they may deliver and reach their goals.

To those of you not caught up in the imagery of football, you might recognize that these are some of the same traits that characterize successful adaptations of Agile Software Development. With the goal of delivering continuous and valued improvements to our applications and supporting software, the Softlayer Development team practices many of the Principles behind the Agile Manifesto. While "moving the chains" toward the end-zone alludes to the incremental success of an NFL team's offense, we speak more in terms of functional and valued releases towards achieving greater customer satisfaction. This is afforded to us by the skilled players on our team, constant communication, and a continued focus on producing measurable results. We are determined to keep "moving the chains" so, stay tuned to the Developer Network, Forums, and all channels Softlayer as we continue to push towards our goal.

-DJ

Subscribe to speed