The necessity of lifelong learning

Live as if you were to die tomorrow. Learn as if you were to live forever.
― Mahatma Gandhi

The term “lifelong learning” sounds nonsensical when you consider that learning from experience is an intrinsic function built into all humans and animals. But today, this term in the context of rapid advances in the field of AI and automation carries a different meaning. This is an attempt at discussing why it’s increasingly needed today, and encourage everyone to take up on actively learning and expanding your horizons if you haven’t started already.

The pace of technological advancement

The consensus is that what you learn today will be out of date within 5-10 years from now. By that argument alone, it’s a no brainer that we should keep learning. The pace of advance is almost tangible when it comes to technical fields and not taking time to update yourself would be a critical carrier mistake. Since my experience is with computer science, this post will focus more on CS but I believe it holds true for most other areas as well.

I doubt there’s any other field that’s advancing as fast as CS at the moment (definitely subjective:)). Most of us working in the field acknowledge this fact and accept the challenge, and even call it an endearing quality. At any rate, the changing of tools is expected every 5-10 year period in CS so this shouldn’t be anything new. However, just changing of tools will not be enough if you want to get into emerging CS topics such as Internet of Things (IOTs), Software Defined Networking (SDN), Deep learning .etc. Here online courses can help in two ways.

1. You probably will need more maths and/or computer science fundamentals such as operating systems, networks, algorithms .etc. This is where MOOCs and especially Khan academy can be of great help. They can help us revise old maths lectures and fundamentals.

2. Once in a while there are wonderful offerings on such emerging topics by pioneering researchers, and usually these courses are awesome.

Automation and consequences

Marc Andreessen famously wrote sometime ago software is eating the world; now probably it’s time to say specifically that artificial intelligence is eating the world, or at least it’s going to. With ever increasing computational power and lifelong efforts by some great scientists, today we are seeing very exciting advances happening on weekly basis. Even though it took self-driving cars and Watson to bring AI to the mainstream, AI has been here for almost as long as the computer itself. From coining of the term in 1956, it has undergone through various stages of evolutions. From the golden era of logic based reasoning to the perceptrons and subsequent AI winter through to the advent of neural networks and current deep learning frenzy: AI has indeed come a long way.

There’s no question of this wave of AI and automation going to affect the way we work. The question is how much it’s going to change; and do we really need to worry ? After all, during the last century the world saw some major revolutions in the way humans work and why this should be any different ? With every major disruptive innovation, there have been both expiration of traditional jobs and creation of new jobs.

One main difference I see with AI based automation is that it’s not trying to emulate a single function like traditionally how it has happened. For example, horse-driven carriage to automobiles, or papers to digital media have revolutionized human civilization as we know it. But in each of these cases they were limited to one specific area. When we think of what’s happening today with AI, it’s trying emulate some skills that have been intrinsically marked as human territory and doing so to the degree of human precision: cognition and decision making key among them. With such faculties been outsourced to machines, there’s no telling of how widespread the affect will be.

While machine learning researchers caution the world to brace for mass outbreaks of unemployment cycles, some opinion the effect will be similar to disruptions happened in the past. While I agree with the former school of thought, i doubt anyone has a good estimation. This is probably why the Whitehouse policy paper for AI discusses on both overestimated and underestimated influences. Indeed some effects are quite unexpected. But looking at how things are going, we can already see some industries like transportation are due for a rude disruption. Here is another estimation of what type of jobs are more prone to overtaking. It can be expected that single-skill jobs will continue to decay while jobs that require social or maths skill will remain largely unaffected or get more demand.

In summary, think we can all agree on that this wave of AI is going to affect how we work, and as the wise say: it’s good to be safe than sorry. If you still think this may be into the far future, time to think again.

Technology domain is interconnected

Again this is mostly with regards to computer science, but it may hold true in other fields as well. Today, to get some meaningful work done, you usually need to tread upon at least a few cross disciplines. If you are a software engineer, it’s not enough to know the fundamentals and a few languages; depending on your flavour, it may be into systems, embedded systems. etc or distributed systems, web security, big data and ilk. If you are into data science — a cross discipline to begin with — there’s no escaping from learning, from statistics to CS and everything in between! Each of these field is vast on its own and advances rapidly just like most areas in CS. In that sense, the words “Try to learn something about everything and everything about something” is apt today than any other time.

With such a large scope to draw from and a rapidly advancing industry, I doubt any traditional college can satisfy the need no matter how good the degree program is. Fortunately, today we don’t have to look beyond our browser to learn whatever the topic we need to learn and the only question is whether we are ready to expand our horizons.

A modicum of balance to a knowledge driven world

With the ever persistent brain drain from developing countries and today’s demand for knowledge driven industries, most of the countries are at a severe disadvantage. With the imminent wave of automation, this kind of overwhelmingly biased world doesn’t look promising to begin with. Luckily, some very wise people, who are also happen to be leading machine learning researchers, kicked off the drive for today’s online learning initiative in parallel to the rise of AI (this is not anyway discounting the wonderful service rendered through MIT opencourseware prior to the arrival of MOOCs). So it’s not an exaggeration to call such learning initiatives as great equalizers in education and a step towards improving world’s future living standard. As with everything else today, some of them are increasingly getting money driven now, but still they have started something that could change the world for the better.

What should we learn

Little humble bragging: I was an early adaptor into MOOCs (as they were coined later) in 2011 and finished both Prof. Andrew Ng’s first online machine learning course, which went to become Coursera, and the first intro to Artificial intelligence course by Prof. Sebastian Thrun and Peter Norvig, which was the start of Udacity. From then to date, I took part in many courses, but as the norm with MOOCs finished only a dozen or so in truth. Anyway, I’d say I have a fairly good rapport with MOOCs as you can get, and would like to share few tips solely based on my subjective experience.

When it comes to learning, you can spend time on lots of things very similar but gain very little in return. In that sense, the classic “Teach Yourself Programming in Ten Years” by Peter Norvig is something everyone should read on what to learn.

Another lesson I learnt is that even though courses are free and limitless, your time is not. So even though a course is really interesting, I now carefully take time to decide whether that’ll help me to expand my knowledge in something I really need. Also rather than trying to keep up with bunch of courses at once and not getting anything fully done, restricting yourself to few depending on your schedule and fully concentrating on them is far better. Again, this is a no brainer, but our impulse is to grab everything free.

Another recent development is all the online services are introducing specializations and mini-degree programs. I have doubts whether this is the best way to go from a learner’s point of view. One of the advantages of online learning is that you are not restricted by any institutional rules to select what to learn and from where. But with this type of mini-degree programs, we are again bringing in traditional restrictions to learning. Instead I’d prefer to select my own meal, and if they are really good, pay for them or audit until I’m convinced. But again, this is very much subjective.

In conclusion, learning is an intrinsic function built into everyone. But with this new order of the world, learning has turned into a fast track lane and if we don’t catch up to the speed, world may move forward leaving us stranded.

Machine Learning in SaaS paradigm

Our ultimate objective is to make programs that learn from their experience as effectively as humans do. We shall…say that a program has common sense if it automatically deduces for itself a sufficient wide class of immediate consequences of anything it is told and what it already knows.

John Mccarthy, “Programs with Common Sense”, 1958

Machine learning has been and still is a large part of research area in academic circles. But in last decade or so it has made heavy in roads to the practical world of tech industry and today it’s no secret that most of the large players are using numerous machine learning techniques to enhance various aspects of their workflows. In this post I’m hoping to look at few ways how a SaaS application (presumably run by a startup) can use machine learning to enhance its overall experience.

Personalise user experience

In your experience of using SaaS products, how many times you may have found that your favourite item is at the bottom of the list and you have to scroll half a mile or navigate through several layers of menus ? Usability usually favours the majority and you may discover the bitterness of being stuck in minority.

If you go into the same coffee shop every morning and buy the same drink, if they are any good at their business then they should know your preferences after few days and you don’t have to go through the ordering routine everyday.  It may be just that the shop owner confirms “Same as usual ? ” and that’s it.  So if your app is bit more intelligent (good at its business), it could do the same and not irritate users by dropping their most used features to the bottom of the page and having them crawl over the page every time they use your app. However to be on safe side, just as in the case of coffee shop owner’s confirmation you may need to give an extra setting option to the user confirming whether it’s preferable for the app to learn user behaviours and adapt.

Reduce your support requests

Say you have a hot product in your hands and it’s getting more and more traction. If you have experienced this situation, one thing that you won’t miss is the number of support requests that’s sky-rocketing in parallel to the hotness of your product. Given that startups have limited man power, there’s no need to emphasise the importance of your team’s man hours and whether to spend them answering easily avoidable support issues or somewhere more useful fixing bugs and adding new features. The school book remedy in this situation would be to evaluate the usability of your app which certainly is a good option but it doesn’t hurt to make your app bit more intelligent to identify obvious pitfalls.

In your neighbourhood if you notice someone is wondering back and forth looking up and down wouldn’t you assume he is lost and offer your help ? Taking a leaf out of this situation your app can do the same and be kind enough to identify a stranger wondering throughout your app and offer him help. Not only will you be saving your team’s man hours but you will be saving user’s precious time and as an added bonus impress the user even more so on your product.

Make search intelligent

Search is a window to your application data and improving the quality of search will directly influence the user experience.  Rather than making the user guess under what keywords his target content is indexed under, what if your application is good at identifying user intent behind the search ? That would certainly be the icing on top of your search functionality. To make it even better, mix some fuzzy-ness  to auto correct a search term when there’s an obvious error. Of course all this is easier said than done and every company is not a Google. But you can take an initiative by analysing search terms to identify week spots, start addressing them first and moving forward as a minor experimental optimisation process.

On another note, a good application wide search will greatly help answer most questions your users may have. From experience most of the support questions are recurring in nature so if users can easily find answers from your community forum or support articles, it will help lighten your support inbox.

Finding more details about users

Well, this is more of a grey area. Gossiping on other’s juicy dirty secrets is usually frowned upon, but a little awareness of what’s going on around you could be useful and even healthy. Most of large companies are already digging up your day-to-day buying patterns to better target you but  the amount of how deep you dig into user information (or abstain from it) is certainly up to you. One way to look at this would be how you treat advertisements – as long as they are relevant and useful in achieving your goal you won’t mind it.  But the second it falls below your requirements and becomes nagging, it will be a nuisance and spamming.  Likewise if you can give users a coupon they can’t ignore it’s likely they won’t mind and you can comfort your conscience by thinking you are doing a service rather than snooping around.

Gauging user reaction to new features

It’s a normal practise for apps to use a simple voting system to get to know most desired new features of a SaaS app. Usually what happen is that app admins put up a set of features they feel important and users vote on them. But taking this one step further and crowdsourcing, you can know what users really need and same time know more about your users. Of course collaborative filtering is not a new technology and most of the social sites are using it to rate new items and know preferences of new users back and forth. So even though you are not running a social network, you can still use it to get to know attributes of your user base such as technical savviness, seeking automation. etc.

Conclusion

This only sums up some of the more obvious situations where machine learning techniques can play a part in improve a SaaS application. It certainly is an exciting field in which I’m trying to get a grasp on as a passive interest and hoping to carry out experiments to learn the applicability of various theories. It would be exciting to hear more ideas and how well they have worked so please feel free to share them here.

Some pointers to get started/keep an eye on:

Avoiding AWS potholes

We are in the era of clouds, and at the moment AWS is the Zeus among public clouds. With its scalable and flexible architecture, cheap rates, secure PCI compliant environment, wide array of loosely coupled services and boasting of 99.95% availability, they may deserve the crown. However they are not without holes and few days ago I got the chance to taste it firsthand. This post is about few measures that you should (and I mean this with capital SHOULD) take before moving your production servers to AWS.

To start with, I had been using Slicehost and Linode as VPS providers for couple of years while tinkering with AWS. After a trial run of few months I was satisfied that everything is working as it should be and moved to AWS for real. But the mistake I’ve done and AWS didn’t bother to mention anywhere easily findable is to couple Elastic Block Storage (ESB) with all instance stores. And this is something easy to overlook when you are coming from a regular VPS provider because ephemeral Instance store is the most counterpart similar device to a slice and you may expect the same behaviour throughout.

So back to the story, everything was running fine until AWS had scheduled a maintenance rebooting of the instance two weeks ago. Nothing much to worry right ? But it turns out that the instance didn’t reboot and there was very little possible to do from the AWS web console. Unlike in regular VPS slices, AWS doesn’t come with a back-door SSH console and it turns out even the staff can do pretty much little regarding an instance store. The only solution they could give me was to reboot the instance few times and if it doesn’t work out…well, they are sorry and it’s a lost cause.

I earlier mentioned the mistake I’ve made. But what I got right was to have several layers of backups including database replication slaves. So backups were running pretty much as expected and there wasn’t any lasting damage done.  And only when you are in trouble that you are glad of the time well spent on emergency procedures.

So rest of the story is very little. I removed the crashed instance, restarted a new one from the custom AMI we had and copied data over from DB slaves. But this scenario could have gone vastly wrong if there wasn’t a redundancy setup and for some unfortunate bootstrapping startup it could have reduced all their hard work to crisp.

I know servers should be up running and having them down is not heroic. But there are few points you should have in place before moving your production servers to AWS.

  1. Have a proper backup procedure in place. Better if replication slaves are in some other server vendor or in another AWS region and have a monitor setup to make sure replication process is working properly. Also it’s better to have several layers of backups running so you will have point-in-time recoverable database copy as well as one day old, week old, month old.etc data copies in worst to worst case scenarios.
  2. Use Elastic Block Storage (EBS) – They are the external USB drives of AWS. Couple one or more EBS with your instance store  and use them to store any data you think is valuable. If your instance die, you can just decouple the block and reattach to another fresh instance and run without a hitch.
  3. Have a custom bare-bone AMI with just the OS and may be couple of basic services. Also have an AMI with fully ready-to-launch setup. This way you can make another production ready instance in minimal time as well as have an option in a worst case scenario where the full ready made AMI doesn’t work. Finally, test all your AMIs to make sure that they are working properly.
  4. Have snapshots from your EBS devices in scheduled intervals.
  5. Use these not so easy to find AWS architectural guidelines in designing your platform.

So as I mentioned it’s not about heroics, but making sure your service not getting reduced to ashes because of some stupid server glitch. As someone wise had noted, better be ready than sorry!

Update:

There is another set of sound suggestions made in comment #4 by kordless for any cloud deployment. If you are into heavy scaling they may be particularly useful.

Steve Jobs effect

As the whole world is mourning the passing of one of the giants in this era who has contributed to shape the tech world to where it is now, felt like I should jot down my two cents of the man in my diary.

Even though he is best known for his creativity, vision and entrepreneurship, in my opinion they are secondary to the wave he truly brought. It is the sense of hope and inspiration to the world.

Society is hierarchical in nature. Usually higher levels have more power and leeway at choosing their own destiny while like or not middle and lower have fewer chances. Steve Jobs’ life story is a fairy tale of my era which stands as a testimony to say that even the most humble man can change the world in outpouring proportions. This in my opinion might be the best thing that can happen to a society and I believe the modern American tech hub benefited most out of it. Generally people make idols out of people with power which usually means politicians whom even the best represent egotism rather than the talent. However, Steve Jobs represented the success based on skill and hard work which made him a better role model and an inspiration to the world.

How many might have inspired from the life of Steve Jobs directly or indirectly? I can attest that I’m one, and Vesess for another. As a successful startup it’s not uncommon we come across one of his famous quotes or quirk in his latest product in our usual day-to-day chit chat. So if a team in the other side of the world resonated with his life story, it’s a testimony to his influence.

This kind of influence doesn’t just come with skills. I’m sure there are more creative designers and more skillful entrepreneurs among the small crowd of 6 billion. However there’s a sense of destiny and fate in his life story, which is unique and a good study in itself to learn about phases of the life. Even though I earlier mentioned his life story a fairly tale, this isn’t a typical one where the protagonist is a goody-two-shoe. His life is congested with extreme successes, failures, light and dark and he was man enough to accept it. This surely made it easier for everyone to approach him without putting him on a pedestal who can do no wrong.

For me, his greatest legacy is his own life story more than any other.

Replication & backups with Ruby

If there’s one thing certain in life, it is the uncertainty. As you go higher up in the ladder of life, the fall grows steeper, risk becomes greater. Same rules apply in the digital world.

In the process of building and maintaining software, there are plenty of accidents, ways to screw things, foolish mistakes and enemies to sabotage work. So most would agree it’s sensible to have some solid backup strategy as your insurance policy in case a disaster strikes your budding app. But when you say backups & redundancy, it sounds really expensive and time consuming, isn’t it ? Well, Not anymore; with all the cloud services floating around it’s possible to have a good data backup plan with few additional bucks. So in this post I’m sharing a general backup approach easily implementable using wonderful Ruby Backup Gem that you could use or adopt according to your application needs and risk.

When it comes to data replication and recovery, there are various aspects you might need to look into depending on the nature/scale/risk of your data. The method suggested here assumes there are 2 servers for the master and slave where you can setup data replication with MySQL. Also this approach was largely inspired by the strategy adopted by Marco Arment for Instapaper.

Here is an overview of the strategy suggested in this post.

Backup Overview

Backup Overview

1) To achieve point-in-time recovery I’m using a simple master-slave database setup with MySQL. This is very straightforward and Here, here are some examples on how to set it up.

2) Install Backup Gem

gem install backup in both master and slave servers.

3) Setup MySQL binary log syncing from master to slave

– Setup Backup config in master (This will create a ~/Backup/config.rb file)

  sudo backup generate --databases='mysql' --storages='s3' --compressors='gzip'

– Additionally create a default config file defaults.rb (Put mail alert, twitter alert configs here)

– To sync binlogs every 5 mins put this code in ~/Backup/config.rb. Do usual SSH key copy procedure to avoid password prompting when rsyncing.

– Update crontab to sync MySQL logs every 5 minutes

0,5,10,15,20,25,30,35,40,45,50,55 * * * * /bin/bash -l -c 'cd /home/username/Backup /usr/bin/backup perform --trigger sync_logs --config-file
/home/username/Backup/config.rb'

4) In the slave, follow the same process as in the master and setup the backup directory + config.rb. Additionally create a default.rb to store common configurations.

– Create config.rb

  backup generate --databases='mysql' --storages='s3' --compressors='gzip'

– Add email, twitter notification settings in defaults.rb

5) MySQL binlogs will be synced with S3 every half an hour. For this add half_an_hour.rb to your ‘Backup’ directory (All this can be put in config.rb as well. But for the sake of clarity I’m separating them based on the frequency).

6) Daily backup a full copy the database to local disk. For this use the daily.rb script.

7) Weekly store a full copy of database in S3. Use the weekly.rb script for this purpose.

8 ) Use Dropbox to store a copy every month. Plus if one of your workplace machine is synced with Dropbox account it will get synced to the local machine automatically and you can burn them to disks.
Use monthly.rb for this task.

9) Finally update the crontab in your slave to run your backup scripts according to frequencies you intend.

#sync every 30 minutes
0,30 * * * * cd /home/username/Backup  /usr/bin/backup perform --trigger sync_backup --config-file /home/username/Backup/half_an_hour.rb
/var/log/cron/cron.log  /var/log/cron/error.log
 
#backup daily
0 6 * * * cd /home/username/Backup  /usr/bin/backup perform --trigger daily_backup --config-file /home/username/Backup/daily.rb  /var/log/cron/cron.log
/var/log/cron/error.log
 
#backup every week
0 6 1,8,15,22 * * cd /home/username/Backup  /usr/bin/backup perform --trigger weekly_backup --config-file /home/username/Backup/weekly.rb  /var/log/cron/cron.log
/var/log/cron/error.log
 
#backup monthly
0 6 26 * * cd /home/username/Backup  /usr/bin/backup perform --trigger monthly_backup --config-file /home/username/Backup/monthly.rb  /var/log/cron/cron.log
/var/log/cron/error.log

So at the end of this process you will have several redundant copies of your database as well as MySQL transactions up to last 5 minutes. In case of an emergency (ie: disastrous SQL query) you could pick up the nearest full backup and apply MySQL binary logs one up till the disaster occurred and you are good to go.

As a last note (not the least) kudos to the team behind Backup gem. You guys made my life lot easier!