Tuesday, May 29, 2012

Bandwidth Optimization



don't let your website crash at that crucial point


Imagine an online contest taking website, or railway ticketing website, as soon as the clock strikes, there are hundreds or thousands of visitors thronging their bandwidths. Such website often get crashed or hanged. They need to make the most of the bandwidth alloted. Bandwidth optimization has grown into an essential topic for Web developers around the world. It's of vital importance to commercial websites especially those which have timed events. There are several examples where this aspect requires a good deal of thought.

Let's look at a closer picture. Imagine data coming out of the server, when a number of users come to the site at one time. The hundreds of HTTP-request made to the server are queued. While the server is a single computer(if we ignore a cloud platform where the request is redirected to another server in place of being queued) . It can handle a limited number of requests at a time. Several requests get timed out either from client or server side resulting in a small percentage of successful requests. The number of requests that a server handles at a time is the bandwidth. This is different from the one which is expressed as the amount of total data which the server provides in a given time often expressed as GB per month, but is generally unlimited if you are ready to spend a little. Such crowded scenario can be avoided by using certain bandwidth optimization techniques. I know a few of them so sharing with you. Don't let your website crash at crucial moments.
  1. Using image sprites Image sprites is a technique where a number of images are clubbed into one single image or a image and it's on-hover image are clubbed together. Such techniques are generally in use for toolbar icons or even those which are to be loaded again and again.
  1. Compress images Images can be hugely compressed to reduce it's size and scrap all unwanted hidden data from the image. For example, in Photoshop you can “save for web” instead of normal save. Similarly, large images can be substituted for SVG vector graphics. A cleverly made vector graphics can be made very small in size, though this is not always feasible. Use a compressed JPEG image whenever possible.
    Use polyclip.js for adding alpha channel to JPEG images. It'a a useful javascript library developed by Zoltan "Du Lac" Hawryluk using HTML5.
  1. Cache images Images often tend to be bandwidth extensive resource. It is best if you ask the user to cache it in the browser. This can be achieved by javascript and is recommended when an image is to be loaded in almost every page.
  1. Minification The script files can be minified to a large extent and it's an obvious first step towards decreasing the total size transferred to the client for a complete page loading. Mnification is the process of compressing script. Minificaton finds out the repeating group of words in file and tries to reduce them to numbers. It also removes all unwanted spaces and trailing tabs to make up a small script file.
  1. Clubbing together the imported files Every web page page is accompanied with a host of supporting files, the stylesheets and script files. All these files are requested from the server in separate HTTP-requests. These requests often increases the loading time. If there are more than three or four such files they can be clubbed as single stylesheet and single script file. The backend can also be programmed to bundle all these files together before sending to the client.
  1. Avoiding Flash I am discouraging Flash but Flash is actually a very high bandwidth consumer. Using Flash content increases the loading time on the client side as well. With the advent of HTML5, SVG etc. (I am not very sure how WebGL ranks in this respect) , it is recommended to avoid flash wherever possible.
  2. Moving to a cloud platform/higher bandwidth At the end, when all the above means fail to make your website stand against a wave of traffic, it is always advisable to shift to a better host providing a wider bandwidth. You are lucky enough to get such huge traffic go ahead and spend that extra dollar to get a next generation cloud platform.
When traffic comes grab it with both hands”

The trick is to reduce the number of HTTP-requests made to the server and compressing a complete page into the smallest possible size. There are many other methods that I don't know and would love to hear from you. Please mention those methods in the comments.

Saturday, April 21, 2012

Touchegg!! WoW!!

No, that's not Mac.. that's Ubuntu *grins*. No, you don't need to write out everything you want on a Ubuntu. You actually don't need to open a terminal unless you love to do so...


That's my usual reply to a window user amazed at the beauty of my beloved 'Ubuntu'. Powered on a gnome 3.2 shell and Ubuntu 11.10, studded with diamond like extensions and completed with touchegg customization my OS is at it's best. So, I thought it is the right time to share with you my Ubuntu desktop.

Monday, April 9, 2012

An Obituary


शोक-समाचार - 'संयुक्त प्रवेश परीक्षा ने ली अंतिम सांस
संयुक्त प्रवेश परीक्षा (जेईई)
(9 अप्रैल 1960 – 8 अप्रैल 2012)

लंबे समय से कपिल चप्पल की मार झेल रही 'संयुक्त प्रवेश परीक्षा' ने अंततः 8 अप्रेल, सांयकाल 5 बजे दम तोड़ दिया| आप 52 वर्ष के थे|

आप प्रारम्भ से ही बड़े सख्त मिजाज थे| बच्चों के देखकर ही आपका पारा चढ जाता और आप उन्हें डराने धमकाने लगते| फलस्वरूप छोटे बालकों में आपका आतंक व्याप्त हो गया| लेकिन बढ़ती उम्र के साथ आपके मिजाज़ में कुछ नरमी आई|

'मानव संसाधन विकास मंत्रालय' के साथ लगभग तीस वर्षों तक आपके मधुर वैवाहिक सम्बन्ध रहे| जिसके फलस्वरूप अपनी युवावस्था में आपके सात पुत्र हुए| सभी ने बड़े होकर अलग-अलग शहरों में अपने पिता का नाम रोशन किया| लेकिन इतने से उनकी सांसारिक इच्छाएँ खत्म नहीं हुई| अपनी ढलती उम्र में भी आपने 'फाईट मार कर' आठ कमजोर-कुपोषित बच्चों को जन्म दिया| ऐसा प्रतीत हुआ मानो वे 'क्वालिटी' की बजाए 'क्वांटिटी' पर ज्यादा ध्यान दे रहें है|

बाद में आपका रुझान कोटा नामक 'कोठे वाली' की तरफ बढ़ने लगा| उनकी पत्नी (मानव संसाधन विकास मंत्रालय) ने कोटा से उनका पीछा छुड़ाने के लिए 2006 में उनका पूरा हुलिया ही परिवर्तित कर दिया| लेकिन कोटा ने उन्हें फिर भी पहचान लिया और तब से उनके सम्बन्ध और भी प्रगाढ़ हो गए| अंततः कोई चारा ना देख उनकी पत्नी ने अपने 'सीरिअल किलर - खूंखार दरिंदे – राजनेता भाई' कपिल चप्पल के साथ मिल कर अपने पतिदेव 'जेईई' के क़त्ल की साजिश रची| अपनी राजनीतिक शक्तियों का प्रयोग करते हुए 'श्री चप्पल' ने 2010 में 'जेईई' पर घातक हमला किया तब से वे जिंदगी और मौत के बीच झूल रहे थे|

लेकिन जेईई के आई.सी.यु. में भर्ती रहने के दौरान ही उनकी पत्नी 'मंत्रालय' ने ISEET नामक अज्ञात शख्स के साथ अपने संबंधों का खुलासा कर दिया| उन्होंने ये भी घोषणा कर दी की 2013 में वे परिणय सूत्र में बंध जाएंगे| मृतक जेईई के १५ बच्चों के साथ अब सौतेला व्यवहार होने की आशंका है|

लेकिन लगता है 'मंत्रालय' की खुशी अधिक दिनों तक नहीं टिकने वाली क्योंकी 'कोटा' नामक उसी 'कोठे-वाली' ने अभी से उसके मंगेतर ISEET पर डोरे डालने शुरू कर दिए है|

शोकाकुल आई.आई.टी बोम्बे, आई.आई.टी दिल्ली, आई.आई.टी कानपुर एवं समस्त आई.आई.टी परिवार|

(इस आलेख का उद्देश्य किसी को ठेस पहुंचाना नहीं है, और अगर आपको ठेस पहुचती है तो इसे मात्र एक संयोग कहा जाएगा ... सायोनारा)
Share it till 'Kapil Chappal' read this :P
with - Rajneesh meena & jotoo !
Shared by Rishabh Jain on Facebook.

Saturday, March 24, 2012

Using purge on linux, never again!

Don't ever use the purge command with a * on a linux machine unless your hate your system. Yeah, that's the crux of the story I am going to tell you. The warnings are meant for you - read it.
In the quest for making the most 'out' of my laptop, (I guess that best explains my actions) I was jovial for running the best of both gnome and unity on my Ubuntu.The joy was not going to last longer than a few hours. Gnome had been running butter smooth with all awesome extensions installed. Now, the desktop cube feature on unity was also successfully. To add to my success, the IITD caldav server was synced to my alarm-clock signalling the time for windows uninstall.


But, the MAC was always a plus one with it's multi-touch touchpad. The only thing I wanted was that somehow, touchegg, utouch and synaptiks could be made to run such that the three fingers drag can show MAC that ubuntu can do it with three fingers what MAC does with four.


Step one : Re-install all three required software.
Result : No change, no new applications created in applications folder.

Step two : Remove touchegg and utouch.
Observation : touch egg removed easily, utouch has got a lot of files and installations, so       perhaps utouch* will do the job
Action : sudo apt-get remove utouch*
Observation : blah.. blah.. unable to get lock.. blah.. blah
Action : sudo apt-get purge utouch*
Result : ****Doom***

In what number system will 14 X 2 be 92?


So, my friend just said referring to an old calculator that it gives 14 * 2 as 92. It was meant to be just an example, but the equation raised a question in my mind whether in any number system will the equation hold good. So, I did some paper-work and found some interesting results while searching for the required number system.
The first point is to note that if the base is greater than 10, the number shall be less than 28 and if greater than 10, it shall greater than 10. While any system lower than 10 won’t allow for the digit 9. So the given equation can’t be correct anywhere.
LHS is 14 * 2, so the system has to be greater than the 4-base, for the digit 4 to occur. Let’s check out 5-base, here 14 * 2 is 33. Yes, now it becomes very clear that the equation is not valid in any system. You see that in the highest value among the possible number systems is 33. So, any possibility for numbers greater than 33 is not possible for 14*2.
Now,
  • In 5-base system :           14*2=33
  • In 6-base system :           14*2=32
  • In 7-base system :           14*2=31
  • In 8-base system :           14*2=30
  • In 9-base system :           14*2=28
  • In decimal system :         14*2=28
  • In 11-base system :         14*2=28
  • In 12-base system :         14*2=28
  • In 13-base system :         14*2=28
  • In 14-base system :         14*2=28

The most interesting fact is that for all systems greater than 8, the equation holds good. So, we have a new question, why only after 8?
Keep thinking!!