InfoQ: Events Are Not Just for Notifications:
It is nice to see a fantastic explanation of what I think of as Event Programming. I have blog about a way to implement a simple Javascript dispatcher and implementing a cross platform event system. And have been chomping at the bit to implement a fully audited application that stores all the events in one of these new document databases (MongoDB, Riak). To be able to mark any user session with an error (or even allow them to report an error) and then to "replay" that users session would be pretty hot. The concept is difficult but implementation is so much easier especially testing. Now to just evangelize until it is considered a "Best Practice".
Hacking Thought Blog
Ranting about writing software...
Tuesday, December 6, 2011
Thursday, October 20, 2011
Presentation on Cloud Deployment & Mongodb @ Charlotte Python Group
A few weeks back I have a presentation on using Fabric to deploy Python WSGI application in the cloud. The slides are:https://docs.google.com/present/view?id=dg3v9j47_210cxt77g7h
The code from the demo is here: https://github.com/lateefj/RTC-example
In the presentation I displayed how taking down one node in the cluster would not interrupt the other two nodes. Using fabric this was not only feasible but relatively easy once you understand the architecture. I also review the tools that I used like supervisor to restart WSGI (Flask), fabric for deployment and servers setup and finally mongodb for data storage.
I also quickly introduced mongodb: https://docs.google.com/present/view?id=dg3v9j47_212g2kvq2tv
The main point I was trying to make was that in early development RDBMS strict schema just get in the way of fast development. It is a great tool for prototyping. I use it anytime at the beginning of a project because I don't know the final data model. Also my past experience is that every mature application that has an RDBMS is that the schema is totally crazy to work with. So why not start with a very flexible schema and give it some room to evolve as the application matures.
The code from the demo is here: https://github.com/lateefj/RTC-example
In the presentation I displayed how taking down one node in the cluster would not interrupt the other two nodes. Using fabric this was not only feasible but relatively easy once you understand the architecture. I also review the tools that I used like supervisor to restart WSGI (Flask), fabric for deployment and servers setup and finally mongodb for data storage.
I also quickly introduced mongodb: https://docs.google.com/present/view?id=dg3v9j47_212g2kvq2tv
The main point I was trying to make was that in early development RDBMS strict schema just get in the way of fast development. It is a great tool for prototyping. I use it anytime at the beginning of a project because I don't know the final data model. Also my past experience is that every mature application that has an RDBMS is that the schema is totally crazy to work with. So why not start with a very flexible schema and give it some room to evolve as the application matures.
Sunday, June 12, 2011
Startup Cloud Cluster on a Budget
This blog will cover the concepts and overview of the solution and the technologies used for the implementation. The second blog will cover the configuration and deployment.
3-legged Table
I have come to the belief that for any service to compete it has to be supported by a three legged table where the legs are Robust, Fast and Accessible. Without any one of these the table is only valuable to produce heat in the fireplace.Robust
Web systems should not have “scheduled downtime”. I think that the convergence of two things have force us web developers to architect for 0 scheduled downtime. The first is to provide a 24/7 business platform for our users. The second is after launch the software is alive with continues updates until it gets turned off. Traditional business systems ran during business hours and then could be “maintained” from 5pm pacific time to 8am eastern time. There is a general move to a continuous updates of software where the more frequently the updates the more stable the system is and faster the technology can adjust to the business need (I am a fan).Fast
Usage can be directly correlated to the performance of a service. In a competitive market slow services will not be able to compete. Premature optimization has been the road to ruin of many a project but the ability to quickly optimize the service after launch will decide the success of the product.Accessible
The point of a service is for it to be access by users. One of the reasons I think that JSON became so popular is it simplicity. Again in competitive markets the barrier to entry approaches zero. This mean well document services that support 80% of the platforms (mobile, desktop ect) is a requirement to compete in the marketplace.Tools
Linux
This is a given for they types of service that I build. I could see a specific service that was for M$ that required using libraries that only work with Windows however I don’t image easy would be a part of that setup. Specifically I use Ubuntu however the configuration files / deploy script could very quickly be changed to use any Linux / BSD distribution.Fabric
Fabric is a Python tool for doing system administrative tasks. There are a lot of tools that do this most are pretty specific I find this tool provides the best balance between easy of use and flexibility. The problem I have with shell scripts is they tend to be great to start with but quickly find the limits when needing to do some string manipulation.Nginx
This is my web server of choice at the moment. I don’t think this matters so much but it provides very simple and quick configuration which is key the the easy part of setting up a cloud. Ultimately most web service is going to run proxied by something like this that will do all the gzip compressing and static file serving ect.MongoDB
Mongo is one of those new fangled database under the NoSQL (not only SQL). I think it provides the most general purpose and easiest to setup. The console is very easy to manage data. However for this exercise the critical part was the two line configuration change difference between master and slave. This made failover very simple. I think that redis would have also been as easy and the configuration probably as simple but I liked having some of mongo’s mixtures of traditional and modern features like having indexes and map/reduce support.Architecture
In this case I am using a load balancer (http://www.rackspace.com/cloud/cloud_hosting_products/loadbalancers/technology/) which I am not exact sure the specifics but they suggest only need to configure one load balancer it is automagically high availability. We also assume that the client that is talking to mongo has the proper settings that it will automatically roll over to the slave if the master goes down. There is not panacea we still could have a data center failure (as happend recently with Amazon cloud) so we might want to locate a slave replica in another data center ect. However I wanted to maintain a balance between highly available, easy to maintain, fast to setup and low cost.Summary
My goal to create a starter cluster or cloud infustructure that focused on highly available, setup in an hour, easy to maintain and most critically low cost solution. I have published a basically template code (https://bitbucket.org/lateefj/easy_cloud) which I will highlight the configuration in my next blog. This example setup that I have uses two virtual servers plus you would have to manually configure the load balancer (took me 2 minutes) but the base price is around 35$ a month which is mind blowingly low cost in time and money for what you get (YMMV this is the minimum it can cost with basically 0 bandwidth usage). I will be hosting all my projects soon on this type of setup soon so I can sleep better at night.https://bitbucket.org/lateefj/easy_cloudWednesday, January 26, 2011
Testing in Python with a bit of Django
Gave a presentation last night (January 25, 2011) to the Charlotte Django and Python group. Base don the feedback I got from the last presentation I tried to change things up. Mainly by using only 4 slides (including title slide) and lots of code. Which I basically just went though writing a test on a django model.
Slides: https://docs.google.com/present/edit?id=0Af1-cNaYamXFZGczdjlqNDdfMTk4ZGN3dmZod24&hl=en
Code: https://bitbucket.org/lateefj/py_testing/overview (still have to fix views.py)
The best part was the discussion (as always). I would love to do a full day on this which would include setting up buildbot and selenium.
Slides: https://docs.google.com/present/edit?id=0Af1-cNaYamXFZGczdjlqNDdfMTk4ZGN3dmZod24&hl=en
Code: https://bitbucket.org/lateefj/py_testing/overview (still have to fix views.py)
The best part was the discussion (as always). I would love to do a full day on this which would include setting up buildbot and selenium.
Monday, January 24, 2011
Erlang First Impressions
I attended an Erlang training Saturday January 22, 2011 taught by Kevin Smith (twitter) of much Erlang fame. I first met him last year when he did an Riak presentation to the Charlotte Ruby group. Anyway he is an excellent instructor (maybe a couple to many emacs plugs ;) and it was an amazing class. It was so good I feel like my brain is a little hung over from the experience (or maybe the beer we had after). In an effort to try to medicate I figured I would write up my thoughts.
The good:
The good:
- Concurrency #1 implementation detail
- Runtime reload of code
- Shell
- Atoms
- Pattern matching parameter over loading / conditional methods
- Message passing as core part of language is easy and wonderful
- Monitor / Subervisor to restart services that fail
The bad:
- Strings (this is pretty bad since it is the most used datatype)
- Contextual termination ",", ";", "." can all terminate a line / function (I almost like it but don't)
- Syntax is 30 years old and has not aged well
- Immutable types
Erlang make concurrency very easy in some ways by making a lot of other programming very difficult. Writing simple service oriented things like key/values stores or simple, reliable CRUD task it is perfect for. Where as for algorithms, string processing and other complex operations it is a poor solution for. Unfortunately I don't have many concurrent distributed problems where the difficult part is getting the concurrency right. However I now understand why databases like CouchDB and Riak are written in erlang. At the moment I am not writing a lot of simple services however I can see how it would be helpful in the future for simple services.
Tuesday, November 2, 2010
Shelving Java and OS X
History.
The nature of the relation I have as a developer is changing with Mac the operating system that I use for development and Java which is currently the language I used second most (could have been #1 but lets not get ahead). I wrote my first Java back in 1998 where I locked myself in a basement to teach myself a programming languge. I started professionally using OS X back in 2003 or so. At the time I was developing J2EE deployed in a JBoss container. So pretty much I have been developing on Mac the last 7 years and Java for 12.
Why Java?
I taught myself Java in college for a couple reasons:
* The compiler was free
* Easier and faster development than C/C++
* Cross platform
All in all I am really happy it gave me a good 10 years of employment and I learned a lot more about software development than if I was focusing on keeping track of seg falts, memory and pointers. Sun slapped an @depricated on Java when it decided to never open source it. Sun and friends controlled the language basically killing the evolution of the language. Even though it did make Java very popular in the enterprise market for new products as well as replacing mainframes. As I saw the companies that control Java (mainly Sun) could send an army of typing monkeys to build their products on. My developer interests were for the language to continue to evolve so that I could maximize productivity and have fun. I think if Java was open sourced a couple years back, then it would meet more of my developers interests. On the plus side my experience with writing Java software means a lifetime of work even though the mindshare of developers is waving good bye (hopefully that is including me).
Why Mac?
* Unix, a decent terminal and all the wonderful developer tools
* Hardware support so plugin monitor and it works, or usb drive or projector
* Pretty does matter even as a developer I would rather work on something that is not hurting my eyes
The last couple of years with the Mac has been a lot of fun. Even when I decided to get a Apple laptop I always thought the move was somewhat temporary and that in a couple years the Linux desktop would catch up and I would switch back. OS X was a great transition not only because it solved a lot of the hardware issues like plugging in second monitor just works, a unix shell and the list of Windows issues (most of which still exist on Windows 7) to many to mention. Back in the early 2000’s Apple was providing an attractive option. Even though OS X has stagnated since Leopard was release for obvious reasons of the devices that start with an ‘i’ Apple has been changing its attitudes toward developers. My current running theory is that it has something to do with the fact that they have vendor locked a lot of developers via the iPhone. I do write some mobile apps but I do it on Android (it was not rocket science to predict a much larger market share to Android years ago) and I am mostly interested in web applications. I can’t blame Apple for not caring about the small group of developers who they do not make money off of via iTunes app or will not be making money off of. We ultimately are just a small niche user group with really loud mouths ;). Apple got the boost it needed to get back into the game with FreeBSD and focused on a good product and the succeeded. If Apple sees the future as selling consumer devices and making a cut on the software it is distributing to the consumer what can I say I am envious.
Java on Apple doesn’t matter.
Apple’s future is on devices and software righten in a platform they control which is currently Objective-C. The more they control the market place and the platform the more value they see they are adding for their customer and I guess they can rationalize charging for it? I am not high and mighty I purchased a Wing IDE license because it save me time and ultimately makes me more valuable. I am a believer paying for software (it is nice to eat). Even I think the small amount for the OS X platform was a good deal with all the software it came with. As a developer the more open the platform / language / environment is the more creative and possibilities there are for me to create value. That is why the web is so awesome. Creative freedom seem to have pass by both Java and Apple these days and that is why Java or Apple or Java on Apple doesn’t matter.
What operating system then?
Short answer: I am working on it.
Long Answer:
Windows being the master of the closed platform that is not an option. From what I have seen and played with on Ubuntu the platform seem solid and the hardware issues are no worse than on any of the other Linux distros. They have a really great package management system. The Unity UI looks pretty enough for my needs.
What about a programming language?
Programming language is less clear. I can use Python for most of the backend programming I need to do. Since web development is mainly IO bound with rare exception I can use Python. I use hand coded Javascript only for trivial things where I only need a couple lines. GWT has pretty much converted me into thinking that it is the way to go for web application so I need something that fast enough to be able to render optimized Javascript. As Java currently also supports Android it would be nice if I could learn one language to do all the frontend development.
Erlang?
Erlang sound fantastic for distributed server side coding. I don’t have much need for writing distributed server things like databases. Sometimes I need to hack a little Python web service and maybe a bit more but I really don’t have a use case unless I start hacking databases.
Foo on JVM?
JVM derived language. Really, I mean really? If any of those languages get ported to another VM that is _OPEN_ we can talk until then GOTO @depricated Java.
C# (mono)?
C# (mono) might not be a bad option for the near term. There is an Android port for mono already http://monodroid.net/ even if the tutorial talks about using it in visual studio this could be a contender. As far as GWT replacement http://projects.nikhilk.net/ScriptSharp S# or script# is the only thing that comes up when I google it. Will this be an open solution for the long term? Will Microsoft decide to do what Oracle and Apple are doing now? I don’t see this as a long term solution because of the risk of it ending up in the same place.
Golang?
Golang (Go) is the the language I like the most however it is in such a primitive stage. On the plus side the language was created by sponsored by Google and both Android and GWT are basically Google open source projects. As much as I would rather not look to another company academia doesn’t seem to be interested in creating programming language (or significantly contributing to open source projects) for developers like myself who are on the ground.
Filling the vacuums.
The Mac vacuum is a relatively small gap to fill since we (open source community) will probably just need to tweak an existing solution. The Java vacuum is much larger one. Java was successful as a backend tool where I think golang and I get the impression erlang could fill. On the frontend I have noticed that Wing IDE written in Python is so much faster than Eclipse or Netbeans (not that this is news). http://pyjs.org/ is a nice port of GWT to Python which means that Python could be a good replacement for both frontend and backend. I think there is still a need for a statically compiled GUI language.
Monday, October 18, 2010
Enlightenment though eventlet
I did a presentation on Tornado Web to the local Python user group a couple weeks ago. There is one annoying thing about Tornado and one show stopper for most development. Tornado depends on pycurl for doing client request which is pretty strange since the core module can do client and server sockets. For any nonblocking to work with Tornado it has to have an implementation using the core Tornado library. So out goes all legacy clients that use Python sockets (very few use nonblocking sockets).
Blinded By Idealism
My first impression was that monkey patching the standard library was ugly. In reality this makes eventlet usable for legacy projects as well as very simple to write backward libraries that support both blocking and nonblocking. I was caught in the idealism trap where I wanted a clean paradigm to exist though the entire stack. Re-implementing all socket libraries is to large a barrier to change mindshare that nonblocking is a better programming paradigm. Especially if the new implementation is dependent on a non standard library like Tornado, Twisted ect.
Eventlet
The PyCon 2010 presentation is excellent overview. Bottom line eventlet provide a synchronous interface to nonblocking io or can just write nonblocking io using coroutines. Eventlet is mature, stable, fast and documented. This makes it very usable right now using existing libraries and the benefit of the improved paradigm/performance can be taken advantage of without much code change. Also as I have had more time to use Go and it concurrency model I am realizing the power of coroutines in any language.
In Practice
This all came about because I needed to write something that would traverse a site and validate the responses based on content type and regexes. Things like correct encoding to making sure the proper data is being displayed on a specific url. So a spider with validators that can be hooked in based on a regex or content type. Writing the test code I was able to create a eventlet server and have it output data so that I could test that the full stack of the spider code.
Yet again I learn though my mistakes.
Blinded By Idealism
My first impression was that monkey patching the standard library was ugly. In reality this makes eventlet usable for legacy projects as well as very simple to write backward libraries that support both blocking and nonblocking. I was caught in the idealism trap where I wanted a clean paradigm to exist though the entire stack. Re-implementing all socket libraries is to large a barrier to change mindshare that nonblocking is a better programming paradigm. Especially if the new implementation is dependent on a non standard library like Tornado, Twisted ect.
Eventlet
The PyCon 2010 presentation is excellent overview. Bottom line eventlet provide a synchronous interface to nonblocking io or can just write nonblocking io using coroutines. Eventlet is mature, stable, fast and documented. This makes it very usable right now using existing libraries and the benefit of the improved paradigm/performance can be taken advantage of without much code change. Also as I have had more time to use Go and it concurrency model I am realizing the power of coroutines in any language.
In Practice
This all came about because I needed to write something that would traverse a site and validate the responses based on content type and regexes. Things like correct encoding to making sure the proper data is being displayed on a specific url. So a spider with validators that can be hooked in based on a regex or content type. Writing the test code I was able to create a eventlet server and have it output data so that I could test that the full stack of the spider code.
Yet again I learn though my mistakes.
Subscribe to:
Posts (Atom)