Friday, June 28, 2013

learning new languages and tools, alone but with help.

I know that many of us are used to learn how to write code in any new language in the hard way, that means doing examples from some web page or reading a book, then we run our code and if something is not working properly, we can use some of our helping options, like 50/50, call a friend or ask the audience.. anyway we will end using google.

What if i tell you that it is possible to get help interactively while doing examples, with explanations about what are you doing, and hints in case you are lost as Lindbergh's son? Yes. it is possible, I just started using codeacademy for learning Ruby in the right way.

But, the thing I like most is that you can teach also, so it is possible to help others to get that knowledge that you hold for any specific language, API, etc.

My invitation is to try this, maybe learn python or ruby, and if you enjoy it learn more and more, but if you have some extra time, please give it back and build some interesting course.

Enjoy the learning.

Thursday, June 27, 2013

to shell or not to shell

For every developer (maybe except for windows developers), one of the most important tools is the TERMINAL, that amazing window is just a door to a fully operative set of element than could give you access to the most powerful ways to control systems.



At the end, the terminal is just a window, what give you more or less option depending of the SHELL that you are using (bash, zsh, csh, etc), but wait, the shell is also a set of commands that interact with the commands available in the OS, because we are developers and we need to help, invent, create, collaborate, etc; we have created tools called frameworks that try to get more a more from the SHELLs.

Thanks to Sergio Rodriguez and because installing ruby and rvm I destroyed my shell configuration, I got hands on one of those frameworks, it is called bash-it, obviously related to bash shell and a plugin/theme based, my first impression was a simple "well, it is good but i miss my previous shell colors", the day after that event I started falling in love with shortcuts, functionality and look and feel.. it was awesome.

But then, Edgar Gonzalez suggested me to test oh-my-zsh, this time a zsh oriented framework that made me said OMG, it is plenty of tools, plugins, themes (in fact they are no accepting themes collaborations because of the big amount of themes available). Playing with that was amazing!

Now, if you ask me for the best one or which one should you use? the answer is: "it depends", are you going to use everything that is available in oh-my-zsh? or, is it enough with the functionality available in bash-it? those are interesting question that only you could answer.

In my case, I am a simple guy, I am not a guy of luxury, and more important.. I love bash, so my "personal" choice is clear.

So, the answer to the title is, OF COURSE, YOU HAVE TO SHELL, and test the different tools. I just hope you enjoy yours as I am enjoying mine.

Wednesday, June 26, 2013

debugging is better if you have logs

If you have been getting errors in your app, and you do not know what is wrong the first thing that hit your mind is "I NEED TO DEBUG THE APP" (usually). That is relatively easy if you are developing in your local environment where only you are accessing or you are doing a standalone app with a cool IDE like eclipse, intelliJ, Visual Studio, xcode or even netbeans; but what happens if your app is a client in a client/server environment.. Ouch, you maybe will have questions like WHO, WHERE, WHEN, WHAT... if you can answer those questions, for sure you will be able to answer the really important question (WHY), because knowing why it is happening you will be able to solve the problem (code, code, code).

To this point I have not said anything new (I hope so), this is the important part:

If you keep track of everything that is happening you will be able to look for the answer to WHO, WHERE, WHEN and WHAT, and keeping that info is what we usually call LOG. Even if you are doing a mobile app, you need to log what is happening, all we know that logs consume space but you can keep just a window (last 5 hours, last day, last 2 days, etc), the size of that window is up to you.

So, now you have logs, SWEET... but wait, if you have a web platform you will have something like this:
  • webserver log (apache, iis, nginx, etc)
  • scripting log (ruby, php, etc)
  • application log (the one that you are creating with your logical structure)
Ouch again, three sources... and I hope you have many clients connecting so you need many webservers... Oops, now i do not know how to consolidate that.. or worse, how do I read that... :(

Do not worry, this is what I really want to share with you today:

There are solutions for logging, but the one I like most is logstash, basically with logstash you can run a process in any machine that is reading whatever is being written to one or more logs, processing, parsing and sending it to another instances where it will be stored, sorted and make it SEARCHABLE, such a beautiful word, so you can get all the logs processed and available in one place, I LIKE IT!! now with this tool you could be doing a better debugging using your logs.



Basically it works like this:
  1. your app/server/whatever generates logs locally (inexpensive, fast, easy)
  2. you have a process reading those logs (it is called SHIPPER) and sending to the search engine, you can use regular expressions to parse each log entry in the client (AWESOME), the timestamp is courtesy of logstash
  3. you can setup a web interface (two or three availables), I suggest kibana that is really good.
  4. search, search, analyze, SOLVE.
It is easy, isn't it?

What now?, well watch this presentation of the creator of logstash at the puppetconf, it is for falling in love with the tool. and then start reading the docs for getting started.

A couple of suggestion:
  • you can test it in your local machine without problem.
  • be careful with the memory usage, you will find different shippers that could help you to use less memory reducing functionality. Keep an eye on that specially if you are using Java.
  • if you are planning a live deploy, please take in count the scalability, I would like all of you having millions of users generating logs.
Two final comments, 
  1. there is no tool that replace you ability to analyze and THINK, take your time to think in whatever you are watching. Making mistakes is ok, what is not ok is to make mistake because "I do not think that.." 
  2. I have not tried to use any shipper in a mobile device, if you found anything please share it, because that is one of the advantages of newrelic.
Enjoy it!





Tuesday, June 25, 2013

It is related to indexes!!!

I am a mongodb user, I have deployed cluster with mongodb for different apps, I like the mongodb way. Taking that as a premise I try to get as much as possible from my different environments and as the creator I tend to defend my platform, but I am also critical of all the problems and if something is broken I assume that it is my fall until I can discard every known point in the platform.

I realized that sometimes it is not my monster the one that is killing the app, could be something that we are not taking care about. After many experiences (some of them really bitter) and a lot of time watching the performance in MMS and custom tools, my friend Tomas Henriquez gave me the link to a tool that contains the revelation of the day:

"9 of 10 problems with mongo are related to indexes"

OMG, DEX from mongolab.org is an opensource tool for indexes analysis of slow queries!!! now a new cool tools for analyzing what is going on with the platform.

BTW, indexes are really important even for RDBMS.