Sunday, August 14, 2016

The reality of failures

Look around your office desk for a moment (you can imagine an office if you are not at office). What do you see? People focusing on the daily tasks, glued to their screens or notepads, crunching numbers, making phone calls, typing text, doing whatever they have to in order to achieve some daily target that is either self established or was handed down by a manager. If you are in your mid twenties to mid thirties, have a career, have a dream that you are chasing, devoting way more time to what we consider "success" then you might have come across my friend called failure.

Failure has been with me for a decade now. Not because I like him, but because he is just everywhere. It is known that majority of startups/new ventures fail. If that majority is like 90% or more, then 9 of us out of 10 could not get to sustaining financial growth or stability. Without that, you can either burn someone else's money or wind down the venture. After that you either start a new cycle, or do a day job, use your skills, grind everyday at work, still dreaming that one day you will be able to bring some change in the world.

But change is already happening. It is the only constant. Am I not changing the way things work in my day job? I sure am, but why does that not count as success? If you asked a graduate student who just came out with a degree in hand and has a dream of a well paying job where she can build things, lead people and have a good life, then I am already there. In fact I have been there long time back. But that is a measure of someone else's success.

The problem with success or failure is how you measure your life versus how others do. What may be hard earned success  to one man may be just a walk in the park to another woman, and she does not see that as success. Over the years the measuring sticks also change. We grow, learn new things, and our perspectives change. When I was in my early twenties my whole measure of success was to build software products, use cool technology and maybe brag about them. Now it is more about solving someone's problem, the cool shiny toys are not as important anymore. But it is not just about what I do 8-12 hours of my day everyday. It is also about my life or what I think it should be. 10 years back I would not have thought about traveling around the world, making friends, knowing cultures, or having "just" good life. I would have hated these things because they meant nothing to me then. I was all for the glory of new companies trying to change the tomorrow, working crazy hours and not even thinking why I was doing that. I am sure we all have been there for a while.

The older I grow, I measure success and failure differently. And I have to chase these new targets that I deem as success. Things like mentoring others, spending time with friends, seeing the world give me more satisfaction now than a few years back. And I am gravitating towards doing more of these. So why does failure still stick around? Perhaps because I want him to. Because I need something to tell me not to stop moving forward, not to settle for anything less that what I deem as greatness. Perhaps just peer pressure sometimes. Greatness does not have to be a millionaire founder or a rockstar programmer. What is important is to accept that our lives are how we want to measure them. The measuring stick is created from our environment, with our own and others thoughts mixed together. Success and failure will always be together, there is no need for alarm as long as we keep moving towards our personal goals, which will in turn evolve in time. This is the journey, the reality. Without failures it would be a very boring one. Let him motivate you, not threaten you. As they say: what does not kill you makes you stronger.

Have a happy journey!

Tuesday, May 26, 2015

Hackathon HH - 24 hours of awesomeness

It has been three and a half months since I relocated to Hamburg, DE. Working at a medium sized company is a very different experience from the entrepreneurial life I had for many years. The work is fun and it comes with consistent salary at the end of every month so that I can enjoy personal life. But once a while I have the urge to keep on working through the weekend and hack something. The urgency of a very short deadline and the chaos of a project without good specs is still very attractive.

That opportunity came knocking when I attended the Hamburg Hackathon last weekend (23, 24 May 2015). It was a 24 hour hackathon starting on Saturday at 13:30 hours and ending on Sunday at 13:30 hours. I have participated in Yahoo! OpenHack and other hackathons before and they were very large hackathons, with up to 400 people, very enjoyable, and very well organised. So when I went to the Hackathon HH, I had very mixed expectations. But I was very pleasantly surprised.

The hackthon was in its second year, and the level of organisation was already very high. Everything was on time and the organisers were very well coordinated. The venue was very fitting, and as far as I understood it was an old factory or warehouse turned into a startup hub. But the best part was the people. It was a surprisingly mixed bag of folks, not all weirdly geeky, but everyone was very curious to learn and do something.

The weather turned out to be great. It was sunny for the most part and very comfortable temperature. There was a surprise fitness bit where all of us participated for about half an hour of workout outside. It was certainly relaxing after many hours of sitting. When I went to the venue on Saturday morning, I had no intention to stay all through the night. But the overall atmosphere was so inviting that I felt I should have taken a sleeping bag. Sadly that was not the case, so I took a short sleep at home and went back early morning on Sunday.

The anxiety before the deadline was visible on many faces. But everyone was very much enjoying the whole experience. And for me that is the defining purpose of a hackathon - to learn, and experience what it feels to build something in a compressed time with like minded people, mostly strangers. The sponsors had different prizes for various categories, but most had prizes for best apps to use their APIs. Although winning prizes was not my aim, but I did feel like missing the chance for the LEGO sets there were awarded by Twitter. Leaving that bit aside, the hackathon ended on a very high note and I returned home with more determination to spend time learning new things and doing better hacks.

A big thanks to the Hamburg Geekettes and AppCamp

Monday, November 17, 2014

It's been a while

Yes it has really been a while since I had blogged last. 2 years, according to the date on the previous post. I have been feeling to write for sometime now, but I guess the feeling was not strong enough to overcome the mental state of not blogging.

I honestly do not know why I stopped blogging in the first place though. Anyway, no use thinking about that. I guess I will try and blog about what I have been doing all this while, what I have learnt, and am learning now. Let's see how quickly I can write up the first meaningful post now.

Tuesday, February 28, 2012

PHP libxml issue while compiling

Today I had some trouble getting libxml to work in PHP. I was compiling PHP 5.3.10 for a client's Joomla site and it needs libxml. The issue seemed to be commonly happening to many people and I came across a number of forum threads on the topic.

The suggestions mostly hover around installing libxml2 development package. This can be done in Debian or Ubuntu by:
apt-get install libxml2 libxml2-dev

On other Linux distributions you may try libxml2-devel

But I had already done that and still libxml was not showing up in PHP. I had the --with-libxml-dir setting in ./configure with no luck.

Then I came across the --enable-libxml setting, which although is not mentioned directly in the `./configure --help`, it should have come to my mind. This is how you enable (or disable with --disable) any module from the ext/ directory. Anyway, I found it mentioned here and that worked! The reason for this is because I had --disable-all option set. So all default modules were off, and I had to enable libxml with its enable option.

Hope this helps someone else...

Friday, February 17, 2012

Building a Yii app: The Data Model

A friend of mine needs a web application to be revamped. I had originally created it about 2 years back using a custom PHP mini-framework that I had built for many projects at that time. The development had stopped for different reasons and parts of his web application were incomplete. For example images were not upload to Amazon S3, which was originally planned. Some Model edits were not working in many parts and there were some data validation issue. He has been doing the groundwork for his business and now has decided to finally complete the application.

The application is related to Medical needs, information about patients, doctors, hospitals etc. I have decided to make the new version using Yii, since some other developer will take over if the project is successful and Yii (or other popular frameworks) is a very well documented framework for anyone to use. The choice of Yii against other PHP frameworks is rather just an impulsive one. I have read comparisons of the good PHP frameworks and Yii is among the top few. Anyway moving on...

While I am building this application, which is a moderately feature rich one, I intend to write about my experiences. Hope this helps anyone looking for a quick introduction and example for Yii. I am trying to make this a tutorial for Yii, I will try my best here. The project needs data for multiple types:
  • General User Profile (could be a patient)
  • Doctor
  • Hospital
  • Nursing Home
  • Other Medical companies like: Medical Shop, Diagnostic Center, Fitness Center, Ambulance Provider, Nurse, etc.

Other information include:
  • Specialization: this is related to Doctors, explained below
  • Address: City, State, Country, etc. Any entity can have multiple addresses
  • Phone: can be either a fixed or a mobile (cellular) phone. Any entity can have multiple phones, also address can have phones associated with them
  • Department: Hospitals or Nursing Homes can specify many departments
  • Branch: Hospitals, Nursing Homes of Other companies can have multiple locations/branches.
  • Image: multiple images for any entity.
  • User: this is used for authentication, simple email/password for now.
In order to manage the mappings of many entity types to Address, Phone, Branch, Image etc. I have used a central Entity table. Every type of physical entity has an entry in the Entity table (including each branch). Then Address, Phone, Branch, Image, Department are mapped to Entity table.

In Yii terms the relations look like this:
  • Doctors can have one or more Specialization (HAS_MANY in Yii Model)
  • Doctor, Hospital, Nursing Home, Other, Profile have a one-to-one mapping to Entity (BELONGS_TO in Yii)
  • Entity can have multiple Addresses, Phones, Images (HAS_MANY in Yii)
  • Entity can have many Departments (HAS_MANY). This is limited to only Hospital, Nursing Home or Other types though at the application level.
  • Entity can have another Entity as Branch (HS_MANY). This is also limited to Hospital, Nursing Home or Other types at the application level.
I will write about setting up Yii Models in the next blog entry...

Saturday, February 04, 2012

Trying out non AWS options

I have been using Amazon Web Services for all of my (or companies' I work with) compute or storage needs for the last 4 years. That include AWS S3, EC2, SimpleDB and even RDS (at MobStac). For the last few weeks I have been planning the platform choices for Mag. It does include AWS DynamoDB, S3 and EC2, but the picture is a bit different.

Amazon DynamoDB guarantees a lot of performance and I personally do not want to take database headaches. DynamoDB pricing model is great to start with too. It is not cheap, but does not bite at the same time. And you continue paying as you grow. The data model is similar to other NoSQL services and you can shift out later if you want.

AWS S3 is a really reliable, cheap storage solution and there is no doubt we will use it wherever we need. EC2 is great for its scalability or its powerful solution to failure handling. Bringing up a pre-configured EC2 (many data centers around the world) is fast, easy and cost per hour is cheap.  Also extra processing as and when needed is perfect fit for EC2 Spot Instances.

While AWS EC2 provides all these great services, hosting regular websites and serving traffic is still costlier. Bandwidth is premium inside AWS. Yes they are very well connected, but you can get that from many top quality hosting providers/data centers. Also the machines themselves are not as fast as a good VPS could be. I have been searching for VPS providers with SSD storage, newer processors and RAM. Recently I tested a tiny VPS (384MB RAM) with such configuration and the Apache Benchmark shows better performance than an AWS EC2 instance (Ubuntu, nginx, PHP, APC, apc.stat=0). Although PHP on the VPS was compiled, and I will re-run the tests, but the difference was very visible.

Of course I do not intend to co-locate or manage any hardware. But I certainly want to look at good VPS or unmanaged dedicated offerings. Configuring a VPS/server is not easy too, from firewall to internal network if you run a cluster, but if the pricing differences are worth it, then it makes business sense. And EC2 is never out of the picture. They will be used in parallel but for stuff I mentioned above and not for regular traffic.

Monday, January 23, 2012

Trying out GeoDNS

For the last 3 weeks that we have started working on Mag, we have been talking to a few prospective clients or other knowledgeable folks out there. We want to understand how individuals, SMBs or larger organizations use Social Media or the Internet in general. Of course all of these initial meets are local to Bangalore and a few in other cities in India (over the phone).

We have been getting a very positive response and although we are building a truly global product we want to first cater to people nearby, learn and expand gradually. Thus it becomes important that we serve the Indian Internet audience. Now servers hosted in the US have high latency from India (~300 ms). Of course we host and will continue to host core business data on Amazon Web Services (we have selected DynamoDB), but an Indian serving facility needs to exist (I will talk about serving details later). So one of the first things that popped up in my mind is that this should not be India specific architecture. Not an in.mag.io domain and such stuff. We should have a simple strategy that can scale in any region. Thus enter GeoDNS.

GeoDNS or Geographical DNS is basically responding to user DNS queries with different responses, depending on the origin of the user request. So if I have a server, say per continent, then any user from any continent should be served from the server in that continent. The concept is simple to understand although I am sure its not an easy engineering task. This is where Zerigo helps out. We have used their DNS plans earlier (although Free plan), but GeoDNS is available only on DNS Pro plan. So I quickly upgraded and got a taste of the administration and a demo setup. The setup is easy: you just mention that a particular domain (or sub domain) is under GeoDNS. Then you assign actual server IP addresses per region with a special sub-domain starting with underscore (_).

Example:
_asi.test.mag.io <some.ip.address>
_def.test.mag.io <some.ip.address>

The _def is default, and _asi is for Asia. If you query from Asia, you should that the _asi IP address, else the default. The test worked perfectly fine. You can use a country code too (ISO two letter code) and USA is further divided in 4 regions. Very nice for traffic balancing by region. If you have similar needs, go ahead and try this :)

Friday, January 20, 2012

Schema Example on Amazon DynamoDB

First an apology to anyone who read my previous blog post. I had used wrong rates for throughput capacity. I noticed this since my calculations seemed a little costly :)

Throughput Capacity price as on AWS website, as of today:

* Write Throughput: $0.01 per hour for every 10 units of Write Capacity
* Read Throughput: $0.01 per hour for every 50 units of Read Capacity

Thus as per my example of 7 tables with minimum 5 Read and 5 Write throughput capacity per table, hourly pricing is:
35 * $0.001 = $0.035 (Write)
35 * $0.0002 = $0.007 (Read)
Total hourly cost = $0.042, monthly cost = $30.24

My current database design is using 3 tables. One is for authentication. We will allow users to signup/login using either email+password (MD5) or using FB Connect or similar. In both cases we will store these authentication string(s) in an "Auth" table. The Primary Key will be the auth strings themselves, either concat of email+password or OAuth tokens. The items will have another attribute which will be `UserName`.  I am yet to read FB Connect documentation, so this may need slight re-configuration.

The `UserName` is a PK in the second table which is "User". The items contain common user attributes like `FirstName`, `LastName`, `Email` and many such needed data. The last table is the "Campaign" table where we store campaign configure information for Mag. This has a Hash and Range type Primary Key. The Hash part is the `UserName`, and the Range is the `CampaignId` (unique string generated from the title of the Campaign). Each user can run multiple Campaigns. What I am not sure of is what is the performance hit if all users mostly have only 1 campaign. In that case I think it will be better to store Campaigns as a Set in the "User" table and the "Campaign" table could have just a simple Hash PK named `CampaignId`.

My doubts as of now are what values to set for throughput. I neither want to overcharge myself, nor do I want AWS to throttle the connection. I guess a real example will shine more light. Back to coding now!

Thursday, January 19, 2012

Day One of Amazon DynamoDB

Its been just about a day that I have been going through the documentation of the newly released Amazon DynamoDB. Using the PHP SDK and getting a basic Table up was simple. Right now I am planning the data organization. DynamoDB is a schema less data store. There is a primary key per table which is your main query column, so as to say. I am trying to use existing MongoDB based data mappers and modify them for DynamoDB.

I am planning to use Fat-Free Framework for the back-end. This is basically the management panel's API. All user interface will be JavaScript only, within the browsers. Templates will probably be Mustache. Anyways, back to DynamoDB: once I get a data mapper done, I will release it on GitHub. I am also looking for similar stuff in Python and Node. I am sure in a couple of weeks we will see them pouring over the Internet.

Pricing
I have been doing some pricing calculations. This is important for us since we have a tiny budget to start with. The price of AWS DynamoDB depends on two main things: size of data store and the throughput needed. The size is charged by the GB/month. So a decent 5 GB data store will cost $5/month. But remember there is metadata that AWS stores and you will be charged for that. I will get a better overall idea of the numbers involved gradually but for starters here is the note from AWS site:

"Amazon DynamoDB is an indexed datastore, and the amount of disk space your data consumes will exceed the raw size of the data you have uploaded. Amazon DynamoDB measures the size of your billable data by adding up the raw byte size of the data you upload, plus a per-item storage overhead of 100 bytes to account for indexing."

The other cost involved is the throughput. This is total reads/writes per second you will need, across all your tables. The minimum throughput allowed per table is 5 each (5 read and 5 write). That means that if you initially have say 7 tables, then your minimum throughput is (7 * 5) + (7 * 5) = 70.
Price for read throughput is $0.01/hour for 10 units.
And price for write throughput is $0.01/hour for 5 units.

Thus your total hourly price comes to $0.07 + $0.035 = $0.105/hour.
Assuming 720 hours in a month, your monthly cost for throughput is $75.6.

This pricing is a little steep. Which is itching me to go through the schema design and see what our starting costs are. I had initially not taken the minimum throughput per table into account; which was yesterday. Anyway, I will need a complete table design to judge anything. But one thing is clear: table count is costly if your tables are basic and do not need even 5 writes/reads per second.

Edit: I had calculated the sum to be $0.15 / hour. I am still not out of bed I guess :)

Mag will use Amazon DynamoDB

Amazon's latest announcement (and offering) could not have come at a better time for Mag. I am talking about Amazon DynamoDB here and I feel it is a good fit for Mag.

For the last few weeks I have been looking at many available options for the data storage for Mag. Notice I mentioned data store and not RDBMS. The reason is that Mag's data is really a large collection of configurations for campaigns that our clients run. Yes they may grow in size as we add customers, but the schema is quite simple, at least for now. And I would prefer having a hosted, cost effective service that is fast. I want to concentrate on the application because that is the real power of Mag.

My current choices included the NoSQL systems like MongoDB, Couch, Redis or similar, but honestly I would not want to handle managing the storage myself. And replication, and other stuff. I had made plans to do that though, but now I will be free from them. Plus the move to SSD seems very practical and needed. I am not saying SSDs will help Mag right now, but from the industry standpoint this is a good start.

But what has really made my decision easy is that it is no hassle, no management and it scales when needed. AWS also claims really low latency, very high throughput. Although our reads/writes will be tiny to start with. I will see the latency for myself once I start but I believe their claims for now. From a startup point of view the pricing is good too. Initially free to start with, although its a tiny 100MB database, but its good to experiment stuff. I used basic assumptions to check prices and it seems good to me.

I will see what existing libraries I can re-use to make the transition smooth. Our applications are JavaScript heavy, the back-end (PHP/Python/Node mix) is just an API as such. All rendering done right on the browser. Just JSONs passing here and there. That's it then, lets code!