Architecting for multiple CPUs

There are two popular approaches to building applications that benefit from multiple CPUs:

The application must be written to be multi-threaded.


The application is packaged into small components, and placed in containers that take advantage of multiple CPUs.

You may recognize the first approach as your typical monolithic application, while the second leans towards Service-Oriented Architecture (SOA).

Each approach has it’s advantages and disadvantages. The first approach is popular with developers, as the developer has direct control of the system (whether virtual or not). However, it is less popular with IT Operations because big monolithic applications are harder to manage, and may hog the resources of the system.

In comparison, SOA breaks things down into small lego-sized pieces, and then assembles them together into something useful. This is not a new concept, rather it is as old as the UNIX shell itself. Whenever you use a pipe (|) in the shell, you are effectively taking small programs and connecting them together into something useful. For example:
ls | grep '\.txt' | sort
The component architecture that is used above is the text input and output of the UNIX shell. Because each command depends on the previous command for input, there is little benefit with multiple CPUs. However, programs that take a long time to complete can be assigned a different CPU, resulting in smoother operations.

The potential disadvantage of SOA is that you may end up having multiple pieces, but not a coherent strategy or way of stitching the pieces together. Component architecture and testing is something that should be worked out beforehand. The component architecture defines how these components communicate. Functional tests ensure that each piece behaves as expected. With functional tests, you should know exactly what you’re going to get based on what you put in.

There are other ways to take advantage of multiple CPUs, but the principles are the same. Those are: manage concurrency manually, or break things apart to manageable pieces and let the container (AKA: process, actor, isolate, etc.) manage the CPUs.

Presenting at Toronto Java User Group

Update: I’ve placed the slides from my presentation on Prezi. Example code and PDF is on the Toronto Java User Group site.

I’ll be presenting at the next Toronto Java User Group meeting, on Thursday January 19th 7pm, at the Free Times Cafe (320 College Street).

Here is what I will cover:

Developing for Android using Adobe AIR

1. What is Adobe AIR? (hint: Flash, HTML5, and Native Extensions)
2. Structure of an AIR app
3. Using Flash Builder IDE
4. Using AIR and Flex SDKs
5. Using Native Extensions
6. Developing Native Extensions using Java
7. Questions?

Click here for a map of the location:
Toronto Java User Group

2011: I hardly knew you

So 2011 came and went quickly. There were many challenges and opportunities. Highs and lows for me.

Like many at this time of year, here are my goals for 2012:

Business goals

I plan to move more from service-based consulting to selling software products. This is easier said than done, and may be a longer term goal. Ultimately, companies pay big bucks for results, and results can only be guaranteed by full services. I collated some interesting data that showed that even established companies (in the same field) make 70% of their revenues from services.

I see a symbiotic relationship evolving where the products help push the services and vice-versa. Ofcourse, this means that I have to devote time to both aspects of the business. Time management is going to be critical.

Personal goals

My weight in 2011 fluctuated dramatically (damn you high metabolism). I need to do something to keep my body occupied between long stints behind the keyboard, meetings, and general office dweller lethargy.

I’ve already ran a couple of marathons in the past, so I’m interested in doing something related yet new by competing in a triathalon. Realistically though, I probably won’t have the substantial amount of time to train for a triathalon, so I may have to content myself with the now comforting familiarity of marathon training.

So marathon it is. The difference now is that I’ll start to track my progress. That might give me a fresh perspective. I was never interested in tracking the length of runs, pace, etc. In my mind, the final marathon time was the only number that counted. My best time was 3:21, and I would need to dedicate myself again to break that time.

Another goal is to involve myself in open-source. This would be in such activities as writing, presenting, and in contributing bug reports and source-code. I’ve been doing this in the past, but it somehow ends up for a company that uses the open-source software versus directly to the cause. Gotta go to the source! There are lots of exciting projects. Flex and Backbone.js interest me the most.

OK, that’s it for me. Hope you have an exciting and fruitful 2012.