Why businesses should not obsess over facebook


Well facebook is the very big thing on the internet right now. A huge number of users, a huge number of buzzwords. “Social engagement”, “Social interaction”, “Content curation” and so on. The big tech blogs always rush to inform us about the latest evolutions in the facebook platform. Even if those “evolutions” are something as silly as changing the text of the “like” button we *have* to be informed. We have to be alert, we have to keep up with whatever that is that facebook is up to. Well in case you got caught in that storm, let me clear up some things.

facebook logo

First and most important, not everyone is on facebook. From the total internet population only a part is on facebook. Less than a third. The other two thirds are only on “the rest of the internet”. Second: facebook doesn’t really have 600 million users. There are 600 million accounts registered but most of those people just log in a few times a month (or less). It’s true that for some people facebook is a daily need, but that doesn’t mean that all of it’s users are equally “addicted”. Third: even within the daily users, a huge part is just browsing holiday pictures and watching youtube videos. Nothing that would justify your attention.

Of course facebook and the tech blogs will always claim that something huge is going on. It’s the equivalent of news on TV. Big scary headlines, always something of huge importance, always something that justifies your time. But the world we live in is not like that. Things that justify our time happen rarely. At least not as often as the TV news claim they do. But if one day you open your TV and see the newscaster saying “another boring day in the news”, the first thing you would do is turn it off and carry on with what you were doing before. It’s the same with tech blogs. If one day you read on mashable that “the social web is not that important” what would you do? Carry on of course. And this is what mashable doesn’t want you to do.

The way I see it, facebook is the TV of our generation. Yes it’s popular, yes it’s important, and yes it’s a huge market. But while you should be aware of it, you should not obsess over it. I’m tired of listening to over-exaggerations like “Oh! now adwords is dead”. Have those people really considered that social networks could might as well be what ICQ and instant messengers were 10 years ago? They were popular, they were important but I’m glad I didn’t waste my time developing ICQ plugins.

Update:

A few days after writing this post I read on technorati that facebook sources are reporting traffic losses for the second month in a row. Read more on the original post.

Inspiration from:

(All these Brilliant People at) Facebook Make Me Sad

Why Facebook isn’t the best home for your public events

Why I’m not moving to Ruby on Rails (yet)


When you’re about to start a new project it’s the right time to move to something new. Sometimes it’s a new CSS or Javascript framework, sometimes it’s a new version control system, in my case it was moving from PHP/CodeIgniter to Ruby/Ruby on Rails.

CodeIgniter vs Ruby on Rails

I started out in my windows 7 laptop and came across a myriad of problems. The first time there was encoding problems. Google came to the rescue. Then I had to configure the system PATH variable a few times since there was no documentation to tell me what to configure. It worked out fine. After a lot of hours I reached the point where I have a working Rails 3 installation but no virtual hosts and of course no sub domains. Unfortunately Passenger doesn’t work on windows and it’s developers don’t plan a release anytime soon. So since I can’t find documentation on virtual hosts with ruby and I’m quite tired of googling I gave up on the idea.

Next stop was Ubuntu. The Rails version in the latest Ubuntu is still 2.x. There are no official repositories to give you a Rails 3 installation out of the box so the most reasonable option is RVM. To make a long story short, after a few hours of trying, it didn’t work. I’m quite well aware that other people have had more success than me but unfortunately for me things didn’t work out the way I wanted them to.

In PHP/apache world there are installers for windows that just work out of the box. In any Linux distribution things are even better. So since I don’t own a mac and I can’t spare any more time things are quite clear. The way I see it deployment for Rails is still lacking in options. Maybe Rails is a great way to build web applications and maybe it could save me time in the long run. But the way things are now, it just waists me time. So I’m sticking with CodeIgniter and I’ll revisit Rails next year when it will hopefully be more mature.

How to skyrocket MySQL performance the easy way


When you see your average page loading time going from 0.08 sec to 1.40 sec you know it’s time to do someting about it. I’ve run into this situation a few days ago and made some tweaks to my database. Now the average loading time is even lower at 0.05 sec. Here is how to do it.

MySQL logo

1. Create indexes

Indexes are a way for mySQL to scan through tables very fast. The greater the number of rows, the greater the speed improvement. The mySQL manual claims that in a table with 1000 rows, an index could speed up data retrieval by 100 times.

Let’s see how it works in action. Let’s assume for example that we have a simple application that stores all books in a public library. We will need a books table and an authors table to store our data. Since an author may have written many books, and some books can have multiple authors (like many tech books) this is a many to many relationship. So we also need a books_authors table for relating books to authors. So our tables will be:

1. books

CREATE TABLE books (
  ID INT,
  title VARCHAR(255),
  ISBN VARCHAR(255),
  date_published (date)
)

2. books_authors

CREATE TABLE books_authors (
  ID INT,
  book_id INT,
  author_id INT
)

3. authors

CREATE TABLE authors (
  ID INT,
  name VARCHAR(255),
)

Primary keys are automatically indexed by mySQL so we will turn our attention to the books_authors table. The reason is that there will be a lot of work done by mySQL in that table, since it acts as the glue for the other two. Depending on the type of your select queries you may want to index other columns as well, such as the ISBN column if you want to search for books by their ISBN. However if you make the ISBN unique it will be also automatically indexed by mySQL. This is a great idea since ISBNs are unique anyway.

However, back to our example. Let’s see the code that will create the indexes.

CREATE INDEX book_id_index ON books_authors (book_id);
CREATE INDEX author_id ON books_authors (author_id);

As you may have guessed, the syntax goes like this.

CREATE INDEX index_name ON table (column);

 

2. Query cache

MySQL has the feature of caching select queries along with their results. To make things even better, MySQL serves the same cached results to different clients. A great advantage over classic server side HTML caching. Although query cache is on by default you have to configure the cache size in order for it to work.

To check out the size of the query cache connect to MySQL and issue the following command:

SHOW VARIABLES LIKE 'query_cache_size';

The size of query cache should depend on your server’s RAM. A nice practice is setting it to about half the memory size to allow resources for other services.

To set query cache size to 1MB just do:

SET GLOBAL query_cache_size = 1000000;

The first time a select query is executed it will run at normal speed. However consecutive queries will be returned almost instantly since they will be cached. This will speed up even the most simple applications since routine queries, like “select the 10 latest posts” will practically always be cached.

 

Conclusion:

These two simple tips can have an enormous impact on your web application’s performance. However you should be aware that database optimization is a huge topic and it’s worth digging deeper into it. Your next stop from here should be database normalization.

 

Reference:

How MySQL Uses Indexes
http://dev.mysql.com/doc/refman/5.0/en/mysql-indexes.html

When To Use Indexes In MySQL
http://www.howtoforge.com/when-to-use-indexes-in-mysql-databases

Query Cache Configuration
http://dev.mysql.com/doc/refman/5.1/en/query-cache-configuration.html

If you got comments/suggestions or want updates on new posts be sure to follow me on twitter.

The business renaissance and the culture of open source


In the last couple of days I’ve had the “problem” of having lots of people trying out deskhot. The nice part of my “problem” is that people, not only love the application and start using it right away, but they also move their bookmarks from competitor’s services. The bad part is that the database has gotten very large in a very short period of time.

The creation of adam

I’ve spent the last two days conducting a series of experiments and benchmarks. I’m thinking of replacing apache with nginx and MySQL with a no-db solution like MongoDB. I’ve set up Debian Linux on a couple of computers, installed the software mentioned above and have been testing various configuration combinations since. While I was feeling lost and dizzy from hours in front of a green and black terminal, countless manual pages and forum posts, I remembered how computing was back in the 90’s when I was studying computer science.

Back then it was all about things like Windows NT, enterprise UNIX, Visual Studio and the like. If you wanted to even have a shot at creating a software business you needed money. And by money I mean lots of money. But the real cost was not hardware or software. It was the time and money you had to invest in specialized training from corporations like Microsoft and SUN. Back in 1998 you couldn’t just find a specialized technical answer on Google.

In about a decade the open source movement changed all that. Now everyone who is willing to devote a reasonable amount of time to it, can start a software business. The same enterprise level software available to Google and Facebook is available for free to everyone. Along with documentation and technical support. It’s the equivalent of every school basketball team on earth being able to be coached by Phil Jackson for free.

It’s becoming obvious that over the next twenty years we will experience radical changes in the way businesses are created and operated. The Goliaths of today will be smaller tomorrow and the Davids of today will have a better chance at the future. And the best part of this forthcoming renaissance is that we can all be a part of it.

Einstein would have used Linux


If you’ve visited any tech blog over the last couple of years you must be convinced by now, that Apple is creating amazing products that enhance our creativity and productivity. And why is that ? Not only they are technologically superior but they got a certain different culture. An aura surrounding any Apple product. It’s the same culture embraced by the alternative and successful people. The artists, the rebels, the warriors, the crazy ones.

It sure sounds amazing. You get one of those Apple computers and you join the elite of the mankind. However did you notice something weird about this video? None of these people ever used a mac. In fact most of them lived before the era of personal computing. But what if they had been given the opportunity of having a mac ? Well that’s an easy guess!

Einstein would be too smart for it and would have installed Linux. Muhammad Ali would have repeatedly punched the monitor right away. Bob Dylan and John Lennon would probably be too busy scratching their guitars. Sorry if I spoiled the recipe for success but it really is not that easy.

As a web developer I have many colleagues who praise and love their macs. I don’t think that’s the right mentality for any professional. The moment you start caring about the kind of tools you use is the exact same moment when you give away your focus and passion to Apple’s marketing division for free. It’s not about the tools you fools, it’s about what you do with them.

It’s the right time to quote Hugh MacLeod who wrote in his “How to be creative” manifest:

A fancy tool just gives the second-rater one more pillar to hide behind.
Which is why there are so many second-rate art directors with state-of-the-art Macintosh
computers.
Which is why there are so many hack writers with state-of-the-art laptops.
Which is why there are so many crappy photographers with state-of-the-art digital cameras.
Which is why there are so many unremarkable painters with expensive studios in trendy
neighborhoods.
Hiding behind pillars, all of them.