RSS

Monthly Archives: October 2011

The Perfect Sandbox

I’ve been writing software for over 20 years… and while I’m no longer allowed to call myself a programmer, as a marketing ploy, that what I do. Recently I started having troubles with my primary OSX machine. This straight on the heals of some problems with my backup OSX machine.

The backup works fine standalone but when I plug it into my monitor the sync seems off and it bothers me and my productivity. The primary machine is starting to show lowres icons on the dock and the task switcher. I followed the first set of repair steps and it has not improved.

I have a third system I can use but what I hate most about this is that the 6-Sigma curve is blown and my development environment is ground zero.

So I’ve started thinking about what’s next. Clearly I could put my desktop in the cloud. While google has accomplished part of this it is incomplete and does not address the “programmer” use-case. It also does not take into consideration the local developer only the remote. Then I see my wife’s shinny iPad. All of the software and the OS is sandboxed. Any interaction between applications is “managed”. The applications and it’s data is in a sandbox and they can work with remote servers.

So here’s what I want. I want a semi-desktop version of an iPad with keyboard and mouse. Applications that run in sandboxes. Most of all, when my machine dies I want to place an order for a replacement that comes exactly the way the current one was configured and installed. I want it’s basic behavior to be more like a desktop/laptop instead of an iPad but I want the structure.

PS: I also want some of the benefits from a platform like VMWare and running complete remote desktops… in yet another sandbox.

 
Leave a comment

Posted by on 2011/10/31 in Uncategorized

 

Tags: , ,

Cut the Cord!

Depending on who you talk to or read they pretty much say the same thing. “One big reason that OSX succeeded where other failed is because they cut the cord and started fresh”. And if you talk to the insiders at Microsoft they’ll say pretty much the same thing about Windows. “It’s [Windows] missed shipping dates and quality goals because of the deep seeded need to be completely backward compatible.

Well, Linux is about to or has already branched to version 3. And with vendors like Ubuntu, Red Hat, and others contributing to the kernel and other subsystems… everything has been in “add more code” mode. Much the way that Microsoft has been running it’s ship for the last 20+ years.

With Virtual technology like VMWare, Parallels, and others. it’s time to move on. The need for backward compatibility is over. The desktop needs to be more reliable and stable.

 
Leave a comment

Posted by on 2011/10/31 in Tools

 

Tags: , , , , , ,

Mojolicious and MojoX::Redis

I’ve been looking at the code for MojoX::Redis for a couple of days now and I’m impressed and depressed at the same time.

First the good news. Like many projects it’s open source. The better news is that it looks cool. The code is nicely formatted and if anyone was following the PEP equivalent for perl then you’d say it was adhered to.

On the sad news side of things. While there is some POD doc at the end of the main project file that’s it. The code is not documented at all. And the worst of it is that the code is the exact reason why people hate this crap. This person clearly knows the ins and outs or perl and he demonstrated that aptitude well. But if you asked me to reverse engineer it… it’s going to take a while and a few cases of wine or beer.

The best feature is that it implements non-blocking in a way that complements Mojolicious, however, the first side effect is that the main thread continues to run while the first request is processing. When really the benefit of this sort of functionality is to let peer events run not the current main thread. Since it was not documented in any meaningful way this had to be experienced first hand… and after reviewing the test code I’m not sure that my conclusions from my code are correct.

Anyway, here is an explanation as I see it in pseudo code.

1) do some redis function like INCR expecting a response
2) do a get on the same key
3) compare the results and they will always fail because
the results from #1 have not completed by the time #2 completes.

Some code that demonstrates this

my $retval1 = undef;
$redis->execute("incr" => [$mykey] => sub{my ($redis,$res)=@_; $retval1=$res;});
my $retval2 = undef;
$redis->execute("get" => [$mykey] => sub{my ($redis,$res)=@_; $retval2=$res;});
die "they do not match" if $retval1 != $retval2;

The side effect here is that it simply does not work. The only way to make this work is something like this:

my $retval1 = undef;
my $retval2 = undef;
$redis->execute("incr" => [$mykey]
         => sub{
                my ($redis,$res)=@_;
                $retval1=$res;}
                $redis->execute("get" => [$mykey]
                      => sub{my ($redis,$res)=@_; $retval2=$res;});
              );
die "they do not match" if $retval1 != $retval2;

The effect in the above code is that since the sub() that is called upon completion of the incr() is called when the incr() is completed. The same for the subsequent call to the get(). The last die() will still have the same effect of getting control before the redis calls have completed execution. So fo for this to be effective the die() needs to be inside the sub() of the get(). Phew!

I looked at the test cases in MojoX::Redis and there were some interesting examples. There was an implementation of the redis pipeline in the form of a multi() transaction. This could be interesting since one could do an incr() and a get() in the same pipeline, however, if you needed the result in order to perform future calls then you’d have the same timing problems with the response not being ready or available in local memory for future calls.

An async lib of the redis tools seems novel but it makes certain use-cases very difficult and verbose. For example I was playing with the sinatra example of RestMQ. Sinatra being ruby has many of the same warts, and certainly the ruby version of the lib was not evented like MojoX::Redis so I do not expect that it’s going to get much work done. (I really like their demo version because it is so little code and it so accurately depicts the mission that it’s hard not to like the elegance. Even though it’s ruby.) But the reality is that it is still constrained.

In summary, while Mojolicious is nice and simple to use(I still like it). The simple use-cases are simple but as soon as you advance to the next step this will get tricky. If you track after the “get it to work correctly” and then think about performance you could end up rewriting the project to make it performant. So be mindful.

post '/q/:queue' => sub {
  my $self = shift;
  my $result = undef;
  my $queue  = $self->param('queue');
  my $value = $self->param('value');
  if (! defined $queue) {
    $self->app->log->debug('queue was not in the URL ('.$queue.')');
    $self->render_not_found;
  } else {
    my $uuid = undef;
    my $lkey = undef;
    my $q1   = $queue . $QUEUE_SUFFIX;
    my $q2   = $queue . $UUID_SUFFIX;
    $redis->execute("incr" => [$q2] => sub{
                                           my ($redis, $res) = @_;
                                           $uuid = $res->[0];
                                           $self->app->log->debug('the uuid is ('.($uuid||'undefined').')');
                                          });
    $lkey = $queue . ':' . $uuid;
    $redis->execute("sadd" => [$QUEUESET, $q1]);
    $redis->execute("set" => [$lkey, $value]);
    $redis->execute("lpush" => [$q1, $lkey]);
    $self->app->log->debug('the uuid q is ('.($q2||'undefined').')');
    $self->render(text => '{ok, ' . $lkey . '}');
  }
};

When this code executes… the following output is on the console:

rbucker@mvgw:~/hg/metaventures/gwtwo$ ./alt/restmq.pl  daemon
[Sun Oct 30 00:59:50 2011] [info] Server listening (http://*:3000)
Server available at http://127.0.0.1:3000.
[Sun Oct 30 00:59:51 2011] [debug] Your secret passphrase needs to be changed!!!
[Sun Oct 30 00:59:51 2011] [debug] POST /q/myqueue/ (Wget/1.12 (linux-gnu)).
[Sun Oct 30 00:59:51 2011] [debug] Dispatching callback.
Use of uninitialized value $uuid in concatenation (.) or string at ./alt/restmq.pl line 47.
[Sun Oct 30 00:59:51 2011] [debug] the uuid q is (myqueue:UUID)
[Sun Oct 30 00:59:51 2011] [debug] 200 OK (0.003678s, 271.887/s).
[Sun Oct 30 00:59:51 2011] [debug] the uuid is (19)

My observation is that the output from the sub() is in the log after the rest of the output. Also the error complaining about line 47 is because $uuid is currently undefined when the line executes. Therefore the callback is not merging the execution and therefore any sensible use requires that the code be nested. And that sucks.

 
Leave a comment

Posted by on 2011/10/29 in database, web

 

Tags: , ,

where are all the programmers

[updated 2011.10.26] grammar and a few notes.

This is just a  short note:

It seems that the number of qualified Java programmers is starting to dwindle in South Florida. There was a time when Java was interesting and exciting. The promise of write-one run-anywhere has been delivered, however, in the meantime there are so many other languages that are more productive with few dependencies. Python and perl for example.

Now the question… if you are working in a small development department and you are having trouble staffing the team what do you do? I think it’s a no brainer. Get some strong and qualified manager(s) and then hire as many freshman programmers as the budget will allow.  The cream will float to the top as you develop you project and the standards. The manager(s) will mentor the freshman programmers in the way of the journeyman programmer.

Additionally, you will need to implement some sort of programmer-bill-of-rights and company-bill-of-rights.  This looks a lot like the Agile Manifesto as it was originally written. Finally, stick to the sweet spot in the language you choose and keep the dependencies shallow and light. Lastly, when designing the overall system, make certain that it is possible to support more than one language in the framework. This way migration will be possible.

If you follow this strategy you’re going to accomplish a number of goals. a) develop a team of programmers that is going to cohesive and cost effective. b) there will be a career path since they are mostly freshman. c) you will be able to backfill as you promote because there will be interest in the tools. d) you’ll be able to scale the teams and the code as needed.

If you think this idea is interesting as a way to scale the team, the application, and the workload. Then you should call me and let’s talk. I am currently in the market for a new long term client or project although I’d prefer an FTE position.

 
Leave a comment

Posted by on 2011/10/25 in management, ProgLang

 

Tags: ,

Is the Facebook App really an iPhone App?

Some months ago I remember reading that Apple was denying iPhoneApps that were simple wrappers for Safari. As we have come to accept Apple keeps many of these decisions close to the vest.

This evening I was logging into Facebook when I saw the Facebook App partially render itself and then a number of Safari controls were displayed. In order to test my theory out I brought up Facebook with the actual Safari App on on the phone. And the results were identical except for the toolbar the bottom of the screen.

So now what’s the difference between creating a desktop link to Facebook and actually using their app?

More importantly, what’s the point? How much more information does Facebook receive because I downloaded the app versus using it natively in Safari?

 
 

Tags: ,

Beanstalkd client/worker sample code

The following code is not tested and there is no defensive coding at all. Those are activities for the reader for now. In the next few days I’ll implement the same code in perl and C.  The advantage of this strategy is that some A/B testing and monitoring will let you know which modules need to be rewritten for performance etc… The other side effect is that you can be language agnostic. (I might just try Lua too)

One of the other great side effects of this design is that since there are multiple small applications that are distributed they are easier to debug and extend. (think of all of the advantages of microkernels.)

The Client:

# load the required libraries
import beanstalkc

# make a connection to the beanstalk broker
beanstalk = beanstalkc.Connection(host='localhost', port=14711)

# select the tube that is going to forward the message to your "worker"
# you can have multiple workers listening on the same tube or different tubes
# or a combination.
beanstalk.use('msg_for_worker')

# this is my message's transaction id, it is also the key used to locate the
# data in the cache and it is the name of the response tube.
msg_id = str(uuid.uuid1())

# HERE store the full transaction in the redis DB and use the msg_id as the key

# start watching the response tube
beanstalk.watch(msg_id)

# send the message to the worker
beanstalk.put(msg_id)

# wait for a response (timeout is in seconds)
job = beanstalk.reserve(timeout=15)
print job.body

# stop watching the response tube
beanstalk.ignore(msg_id)

# DONE

The Worker:

# load the required libraries
import beanstalkc

# make a connection to the beanstalk broker
beanstalk = beanstalkc.Connection(host='localhost', port=14711)

# setup a watch for incoming messages over the well known tube
beanstalk.watch('msg_for_worker')

while True:
    # wait for a request (timeout is in seconds)
    job = beanstalk.reserve(timeout=15)
    if job:
        msg_id = job.body
        
        # HERE we retrieve the message/transaction body from the redis DB. and do our work.
        
        # open a tube to the client response tube
        beanstalk.use(msg_id)
        
        # send the response message to the client
        beanstalk.put(msg_id)
 
Leave a comment

Posted by on 2011/10/19 in web

 

Tags: , ,

Scaling REST design

The diagram to the left should give you starting point when designing a scalable system using Mojolicious or just about any kpoll/eventd single threaded/process framework. The same or similar can be said of other daemon type applications that are trying to get a lot of work done without having to deal with all of the complexities of threading. (someone recently posted that threads are the domain of a special few as they are difficult and very heard to get right) and while I agree completely I stay away from threads because the problem is more fundamental/theoretical than that. I just hate the idea of giving up all those spare cycles. (the test is effected by monitoring the thing being tested) I forgot who and what they said exactly, however, threading has overhead that I want to avoid. Of course I should also mention that threading is not cross platform. So, to recap, everything is brute force and locally optimized. And we are leaving the process scheduling to the operating system. We are also going to try to keep all of the data in memory (stay away from the disk).

For those expecting to see some code, I have not made the code pretty enough or generic enough to share but I would like to mention that this has been tested and it works and I will share it shortly… but there are some things to be aware of before I get started. I’m also not going to show you how to install or configure the different components. I will mention, however, that daemontools is a great way to get things started and keep them running.

So first thing’s first. What is beanstalkd?

Its interface is generic, but was originally designed for reducing the latency of page views in high-volume web applications by running time-consuming tasks asynchronously.

What that means is that the client sends in one way messages into the broker, beanstalkd, which then queues until a worker registers to process transactions. Unlike ZeroMQ’s request/response use-case beanstalkd’s method uses channels.

The workers register or read from a well known channel and return the response over a private channel which is configured by the client and provided in the work payload.

The Client’s pseudo code looks like:

- get a GUID
- create a channel from the GUID
- put the GUID in the work payload
- write the work message to the broker over the well known channel
- wait for a response on the private response channel

The worker, on the other hand looks like this:

- connects to the broker and starts reading from the well known channel
- the message is parsed and the response channel name is identified
- the worker performs the required function
- when a response is ready the worker writes the response to that response channel

And that’s it. The rest of left up to the broker to perform. Granted there are still a few remaining bits. In the drawing I marked that the client and the worker used the same instance of redis. This is because the different applications were actually running on the same chassis. This is a good thing because all of the messaging takes place in the same box and never hits the network with is busy and constrained. The other benefit is that the messages being passed from client to server are never marshaled more than they absolutely have to. By passing the request’s GUID and the response channel ID in the actual work payload the overall workload against the CPU(s) is reduced.

Speaking of TPS rates. It’s important to note that everything you do is considered a “transaction”. Therefore reading a transaction from the client is a transaction. Writing a response to the client or the broker would be considered a transaction. So in the example drawing there are actually 6-10 application transactions for every user transaction. Therefore, if your system is clocked at “10M TPS” then when the full application is running you’re only going to get 1/10th of the total TPS if you’re counting user transactions.

Logging… is no different than any other transaction and they count against the overall transaction rates. If you have that same 10M TPS CPU and it performs 10x application transactions per user transaction. And you log 100times per transaction then the system will only process 1/10Kth of the overall capability.

Mojolicious, Beanstalkd, Redis and perl are very capable. In the next week I’m going to put together a template in the spirit of a go-lang implementation of SkyNet. Stay tuned.

 
 

Tags: , , ,

Business Class Communication With Remote Employees

At the moment I’m sitting at my desk in my home office and I have several programs open in order to communicate with me and I hate the fact that I need so many applications and so many duplicates. And it’s not that they are bad applications but they are all bloated, have difference security models, and then there is the elitism of some of them.

Here’s the rundown:

  • Mailplane is my regular eMail client for all of the gmail accounts. I currently have nearly 20 accounts.
  • I use iChat connected to 3 IM accounts
  • I use Adium for IRC
  • Skype and Skype Chat
  • Google Voice (it’s connected to my MailPlane interface and my Chrome browser by extension)
  • A client of mine was using Mio so I installed it once too
  • And then there is FaceTime on my desktop and on my iPad
  • go to my pc

When you look at my desktop most of the apps that are running are actually idle and not running at all. Just think about all that screen real-estate, memory, CPU and network resources that they are consuming. How can this get more normalized? As a business owner and user I want:

  1. simple and functional applications even if they are not integrated
  2. secure so that my competitors are not listening in
  3. not off putting
  4. complete so that I can even screen share quickly
  5. reasonable cost

And something that is compelling enough that I don’t have to worry about keeping those other applications around any more. Can’t we all just get alone?

 
1 Comment

Posted by on 2011/10/18 in business, Tools

 

Tags: , , ,

iCloud is featureless and juvenile

And in conclusion I’m canceling, disabling, and deleting all of my iCloud accounts because for the price it not only does live up to a single expectation but that which it might do is more about vendor lock-in than service, form or function. It’s time for the makes of DropBox, Box.net, crashplan and SugarSync to step up to the plate with everything they can. iCloud is going to fall like a house of cards if they do not update ASAP.

Cue in the flashback ringtone like in the movie/TV “Wayne’s World”

I’ve been a DropBox user for about a year. I really like the Sync properties. I’ve managed to use it cross platform between my Windows box running inside a VMWare Fusion session, my Linux instances running on Rackspace hardware and my several Macs. I like their public folders, media folders and their iPhone application. Sure it’s missing a few things but “this” is a sync function I really like. (I have a 50GB account and I’m considering a 100GB and team account for the family.)

I also use Box.net for smaller files and their plug-ins for LinkedIn and WordPress. Since I can produce proper PDF and RTF versions of my resume and some detailed project work. These folders and documents are inherited immediately by the plugins and I do not have any additional work. It’s very sweet. The immediate challenge for Box is that the desktop app requires a business account. While I am happy that they gave me a 50GB account free for life it’s a pretty hollow victory because they do not have any apps that I can use with it. Clearly I need a sync like DropBox.

CrashPlan is by far one of my favorites. Before DropBox I had a small cluster of machines in the house that would sync … and then I upgraded to the cloud version and I even opted for the non-free desktop software. The good news here is that I have an unlimited account. The better news is that my wife has all of our video and pictures saved in the could and after 5 years of marriage she has collected over 200GB of pictures and video. (One day soon I will need to perform a restore so make sure all of this stuff is good.)

And now iCloud. I recently wrote about iTunes and iTunes Match etc … so I will not rehash that conversation. But I can say that I was expecting iCloud to be more like DropBox and it is not.  iCloud seems to be a slightly more polished version of MobileMe (which I never purchased).

Things started to go downhill when I was required to create a new appleid for my devices. It first I used my current email address but then when I tried to activate some features it wanted to create a new ID… and then the ID needed to be @me.com.  They did not give me a way to change the AppleID and in the end I needed to delete the ID and start again. Of course as I started to delete all the wrong IDs I had used I started getting warning messages from Apple that the “whatever the module data was” was about to be deleted. Since this was a one-way trip I just let them delete whatever they were going to delete and let the chips fall where they may. I can only hope that this did not include my pictures.

The iCloud website it a sugar coated website that is trying to look like my Mac OSX system and while it performs nicely it is strictly limited to the 5 applications. (calendar, contacts, email(and not even all of my Mail.app email accounts just the one @me.com account), find my mac, and the last one escapes me for the moment.) I was really expecting to see a filemanager like iDisk, DropBox or Box.net.

Since my wife and I share our current AppleID for our iPhones, iPad, iTunes etc… I was expecting to be able to share everything else. Well iCloud for storage treats us separately as far as the cloud storage is concerned. So if I had to do it I would need a 300GB account for her and a 50GB for me. (if they could sync my drive like DropBox.) However, the price for this will never compare to what I pay for at CrashPlan and I get so much more for my money.

And that’s when the camel’s back finally broke. I have 2 iPhones with 32GB storage each. I have an iPad with 16GB storage. I have 2 MacBooks with 1TB storage and a MacBook Air with 64GB. Oh, and there is one Mac Mini with 1TB storage too, When I put all of this together and I figure out what is really going where. iCloud just cannot do it.

If you’ve every imagined what a cancer looks like when it makes that connection between itself and the host you can only image that it looks a little like a Mandelbrot. The same might be said of the pads of a chameleon’s foot pads. So as I look back at my first Mac Mini + iPod purchase 5 years ago … I realize that there is a lot more going on here than just a simple evolution. Whether Apple was ready to deliver on the promise that was iCloud or not is irrelevant. Someone at Apple has decided that I am worth $XXX dollars a year in goods and services and they way that they make that happen is with underperforming releases with a splash of eureka. (It’s like a sampling of name-your-favorite-additive-drug.)

Man o man, this is turning into a rant that I was not expecting…

So what is the plan? If things do not change radically over the next year or so I will likely end up going over to the Android side. MetroPCS has a an all you can eat plan for 50/mo (I want to cut the core to ATT completely by dropping my land line). I’ll also get a Dell Z series for about half the price of my MacBook and my MB Air.

PS: Ubuntu One has a change at things. I’ve used their product for a while but they do not have a Mac version. I’m not certain that I need one for now. But there are some interesting options with the VMWare solution. (more on that later).

 
 

Tags: , , , , , , , ,

Website name?

I need help deciding what the name of my project website is.  a) it’s going to use the mongoDB b) and Mojolicious… to store, manage and print mailing labels. This is just a sample project to demonstrate (a) and (b).

 
Leave a comment

Posted by on 2011/10/14 in database, site, web

 

Tags: , , ,

 
One Page Docs

Creating a library one page at a time.

One Page Bugs

Reducing the friction of writing and fixing bugs or features.

Follow

Get every new post delivered to your Inbox.

Join 223 other followers