Author Archive: Chong Lee

January 15, 2010

API in Real Life

An API (application programming interface) is an interface that allows software programs to communicate with each other. The communication barrier between programs has become thinner as APIs have evolved over the recent decades, like our languages have over the years. At SoftLayer, we have plenty of opportunities to interact with many different APIs from various companies. Some of us work with a driver API, some work with SOAP, or some work with XML-RPC for some projects. If you’re our customer, I bet you can easily imagine the number of APIs we use by looking at the products and services we offer. Not only are we a large API consumer, but we also provide a great number of APIs to our own customers. It seems that the interaction between software programs evolves just like our lives.

It’s hard to survive alone in this world. We are social beings, and we need others for interaction. A software program pretty much works the same way. There is no program that is a know-it-all or do-it-all. If there were one like that, I would not have a job. Software can expand its capabilities by working with other programs just like we, as humans, help each other. APIs act as a communication tool like our languages; and, by the way, there are many dialects too.

When a program starts to interact with another through API, it can be compared to a marriage. They are stuck together. However, programs can marry many others. When two programs start to interact, one cannot change its API without the other knowing. It would be as if your wife started talking to you in Danish all of a sudden. Even a small change in an API can cause a very bad outcome. Imagine that your wife told you to throw your socks in the laundry basket and you have been following this rule for years. Can you imagine what would happen if you left your socks by the bed one day? No, it simply wouldn’t work. If you really need to change the rule, it’s time to consider a divorce, in other words, API version 2. As I mentioned, a program can have multiple partners and you can’t expect them to follow new rules all at once. Your best bet would be to write a version 2 and keep the original version for old times’ sake. Trust me, people are very hesitant when it comes to changing their routine, including me. (Why should I touch a working program just because you updated YOUR API?)

Most APIs that I have used and seen are wonderful. I have seen APIs that work like a jack-of-all-trades, trying to do everything for me, but I didn’t like it. I would not like a BLT with onions, eggs and mustard. I just wanted a B.L.T, period! I have also seen APIs that require too many prerequisite steps (invocations) to get a simple result. How many times must you get transferred until you finally get someone to help with your phone bill? Jeez!

Ok, enough of these funny comparisons. I, a biased user, have listed below what I think is a good API:

  • A good API should not change often. If change is inevitable, it should give you plenty of notice and allow backward compatibility.
  • A good API should explain why it couldn’t work instead of the infamous “Error: -1”.
  • A good API should have good documentation, so you’re not left scratching your head.
  • A good API is accessible by different platforms.
  • A good API should be stable.
  • A good API should be simple and comprehensive. It should do what it says it does and it should do it well. Prefer “powerOn()” over “powerOnWhenIdleAndStartServices()”.

A good API implies the readiness of communication with other programs and other companies. It will broaden opportunities for your programs and organization to work with others, just like a person with good communication skills has a better chance of fitting in our society.

March 4, 2009

Web Site Optimization

There are many techniques to speed up the web page load time. This Yahoo developer network article sums most of them. If you own a web site with thousands of daily visitors, some of these tweaks will help you provide a better experience on your web site to visitors.

I’ve been on the CDNLayer development since I started working at SoftLayer. One day I wondered how much performance increase some of these techniques can bring. I chose to implement the techniques below.

  1. Using CDN
  2. Combining multiple JS and CSS files to a single JS and CSS
  3. Compressing JS and CSS
  4. Serving files from 2 different domains

I chose them because they are easy to implement and CDN has become very affordable nowadays. I copied the index page of SoftLayer.com and took 5 different steps to optimize the page. To make the page a bit larger, I added a JS and a CSS file to the index page. So the total file size was about 980 kilobytes.

  1. Step #1: “HTML + 2 JS + 2 CSS + images” served from my server
  2. Step #2: “HTML + 2 JS + 2 CSS + images” served from CDN
  3. Step #3: “HTML + 1 combined JS + 1 combined CSS + images” served from CDN
  4. Step #4: “HTML + 1 combined/compressed JS + 1 combined/compressed CSS + images” served from CDN
  5. Step #5: “HTML + 1 combined/compressed JS + 1 combined/compressed CSS” served from a single CDN host A + “images” from 2 different CDN hosts A and B

The page loads within 2 seconds in real life so I disabled both the disk and memory cache in Fire Fox to exaggerate the result. I requested each version 10 times and here is the average page load time in seconds.

  1. Step #1: 11.976
  2. Step #2: 9.602
  3. Step #3: 9.626
  4. Step #4: 9.123
  5. Step #5: 8.72

First, my test site is not on SoftLayer’s server, it is located somewhere in Pennsylvania. Second, using CDN, thus the files are served from Dallas POP, gave me a good 2 seconds decrease. Third, combining JS and CSS files did not give me any benefit. It was only 2 less trips to the server anyways and I’m using a high-speed Internet so I guessed this would not make much of difference in my case. However, if I had a dial-up, fewer trips to server, even it were only 2, will help the page load time. Fourth, gzip compression reduced the content size and it shortened page load by 0.5 seconds. It doesn’t seem like a big benefit as far as the page load time is concerned but keep in mind that the compression decreased the page size by more than 100 kilobytes. If you have a large amount of visitors, it will help you save lots of bandwidth. Finally, serving files from 2 different domains can reduce a significant amount of page load time. This is due to the limit within the browser itself. Most browsers are set to download 2 files from a domain at a time regardless of how fast your Internet connection is. So if you serve your files from multiple domains or sub domains, your visitors will be able to download more files simultaneously. If a visitor is using a high-speed connection, this trick will help the page load significantly.

I hope some of these techniques can help your sites get prepared for a large number of visitors. Web site optimization techniques not only will reduce the page load time but it will also help extend your web site’s capacity. Who knows, your web site may get Digged tomorrow!

Categories: 
Keywords:
Categories:
February 27, 2009

Different Views for the Same Event

Here at SoftLayer, we try to address customer issues as quickly as possible. Recently, I have been faced with a few more support tickets than usual, which got me thinking about an experience in my younger life. Back in the 90’s in South Korea, my buddies and I were in our early 20’s and it felt like we owned the world. We were full of energy and everything was fun. As Korea is a peninsula, the ocean was a big part of our lives. Every summer, we went to the beach together. There are many beaches as you can imagine, and they get pretty crowded during the summer.

Who wants to work or study during the hot summer days? Come on! Heading out for a day at the beach was a lot more fun.

It was one summer that we went to a nice beach (see picture). Some of us brought our girlfriends and some did not. On the way to the beach, one of my friends, Park, who was single and a decent looking young man, told us about his dream that he hoped would come true that summer. His idea was to rescue a girl from drowning and develop this coincidence into a romantic relationship. Yeah, right. The rest of us had trouble taking his dream seriously. Party’s on!

When we got to the beach, he was busy swimming right away. I suppose he should have been. His chances of being the first person to rescue a drowning woman were about as good as winning the lottery. Look at the picture. You get the idea.

We lost track of him for the most of the day and this is the story he later told us. He was chilling out in the water, on the lookout for damsels in distress. While he was dreaming about his coincidental rescue and romance, he heard a desperate woman’s voice just behind him.

“Help! I got a cramp in my leg.”

Instantly, he was in heart-pounding, breathtaking euphoria; thinking: “Wow, today is the day. Heck, yeah. I swam all day. God helps those who help themselves.”

So, off he goes. He turned himself toward the voice with his eyes strained, willing to risk anything to rescue that woman.

It immediately became apparent the girl was not quite his type at all. He muttered under his breath: “God is busy helping other people as usual”. He shouted loudly so she could hear him with no mistake.

“Sorry, I can’t swim very well!”

And he turned and began swimming back in the opposite direction.

He felt pretty bad after he got away from her; so, he looked back. Surprisingly, the lady had managed to swim to shore by herself. He had mixed emotions after swimming back to shore. I told him, “Don’t feel too bad. I think you helped her build up the mental strength and she found the inner strength to overcome the cramp.”

Clocking back to present, I’ve had quite a few support tickets over the past several days here at SoftLayer. It is not at all as bad as the girl’s situation but I’ve felt a little pressure since it isn’t normal and I’ve got other stuff to do.

Looking back on past experiences, I realize I can view the same event in two different ways, just like flipping a coin. It was a lot of pressure in the beginning to deal with the extra support issues; but, now I’ve learned so many things within such a short period of time. Not only have I learned more about our products, like CDNLayer, but I got a better idea of what customers want. So, drawing in tickets isn’t all bad; it strengthens me after all.

Hey, young single guys out there don’t just walk away from a girl in danger because she is not your type. I guess that’s my point, because I can tell you that my friend remains single to this day.

Categories: 
Keywords:
Categories:
Subscribe to Author Archive: %