Archive for the ‘cubeia’ Category

The Duct Tape Architect

Friday, October 8th, 2010 by fredrik
The Duct-Tape Architect
I have being doing software architectural work for a long time now, and as it turns out, the ‘right way’ of solving things may not always be the best way. Below are two real annecdotes from life in the trenches.
== The Case of the Database Bottleneck
I was visiting a company where we discussed their currenty system design and what problems they were experiencing. Their system had a respectful peak of 7 000 concurrent users and it turns out that at peak times they start to hit the limit of their database which is running as a single entity.
We discussed the regular slew of database scaling solutions such as sharding, dedicated reader nodes etc. and some pros and cons with each solution.
As it turned out however, they solved it in their own way. “Yeah, we solved it. We bought an SSD drive which replaced the old hard-drive, ” they said matter-of-factly.
Naturally I scoffed a bit at this and thought for myself that they have only bought themselves a little bit of time and in best case they could maximum grown by 50-100% but then it would be the same issues all over! Rookies! Surely they did not understand the beauty of unlimited, linear scaling with sharding?
Within one year, they had grown about 20% and was then bought by a much bigger player in the industry and their system was erased from the face of the earth in favor of the larger one. They never hit the limit of the SSD.
Later also did some calculations, if they had grown by 100%, they would have become one of the top5 actors in the market and their profits would have been through the roof.
So when looking back, in this case, it seems like the SSD solution was actually the right thing to do. They only needed to buy some more time for the deal to come through.
== The Case of the Missing Scheduler
Another case occurred when I was reviewing a large gaming network that was running cash games as well as tournaments. There where many tournaments running on a daily basis and most of them are re-occurring events, such as The Daily Lunch Tournament etc. Almost every such network I have known have had a scheduling options for tournaments. You would enter a tournament template and then say something like ‘run every day at 12 AM’ for instance. You would also be able to create a tournament and say ’start this tournament on October 10 at 18 AM’. Then the system would create and start the tournament as specified.
This network did not have that.
Instead, they had about 10 employees in Indonesia who would work in shift and manually create each tournament and then manually click ’start’ to start them. Nuts! This must surely be fixed!
So we started a discussion and I don’t remember my exact word, but they were something like: “This is insane! Surely we should be able to implement a simple scheduler in the system?”.
To which they replied something like: “Sure. But we have made an estimate on the time it would take us, and to cost of the developers that has US salary to implement this equals about 7 years of the Indonesian guys doing this manually.”
Yikes.
“Besides, do you want to be the guy who calls them up and tell them and their families that they are losing their jobs? And for what? Saving a buck after 7 years? We have a choke-full backlog to work on anyway.”
Hmmm. Maybe it would not be worth cutting other features out in order to prioritize a feature that would cause 10 people their jobs and not save any money for a long time. Could this be?
== Summary
Am I advocating that you shouldn’t care about scalability (just buy SSD’s!) or never automate tasks because there are cheap labour to be found? Am I advocating quick hacks and avoiding solid engineering principles? Of course not.
But sometimes it is good to try and raise the view a bit and try to see what *actually* needs to be solved. As engineers we do sometimes get stuck on implementing the ‘right thing’ and lose sight of reality as it comes.

I have been doing software architectural work for a long time now, and as it turns out, the ‘right way’ of solving things may not always be the best way. Below are two anecdotes from life in the trenches.

Read the rest of this entry »

The 30 Second Rule

Friday, October 1st, 2010 by fredrik

Recently I ranted about non-productive tasks that can divert focus away from the developer and seriously hamper the effectiveness in your project. As an extension of that discussion I would like to propose a new rule – the 30 second rule:

Any process that takes longer than 30 seconds to run, must be fixed.

Read the rest of this entry »

How To Start a Low Cost Poker Network

Tuesday, September 28th, 2010 by fredrik

Implementing a poker network is a very expensive project to undertake. There are many barriers to overcome; development, license(s) and player liquidity just to mention a few. The cost and effort involved has proved to be prohibitive to new actors on the market, leading to a fairly stale and static playing field. But does it have to be this way? In this article I will discuss an idea on how to start and scale up a poker network without the enterprise big bucks.

Building a low cost poker network from scratch:

  1. Use open source products
  2. Don’t use real money
  3. Iterate and find a model that attracts players
  4. Evolve into a real money network

But how would I implement the actual points? Read on…

Read the rest of this entry »

About Coding & Effectiveness

Monday, September 27th, 2010 by fredrik

Just the other day a colleague of mine started a small rant of how little time in a development project that was actually writing & fixing code. I think the final crescendo was a Tweet that read:

“My dream is simple. One day, developers can spend their time on actual development..”

It seems that developers don’t riot in the street, they post a message on Twitter or Facebook. Anyway, the nerd-rage was released and so we went back to our tasks as usual.
Read the rest of this entry »

Flash 10.1 breaks multiwindow applications

Tuesday, June 22nd, 2010 by fredrik

Adobe has made their Flash Player version 10.1 available for some time now. Among some more or less nifty features, they also have a new way of preserving CPU and resources when an application is out of view (different tab or minimized), the application is throttled to a meager 2 frames per second instead of about 60 frames per second.

The throttling effects everything in the application, Timers, Events, LocalConnections etc. The behavior is explained very well in Tinic Uro’s blog post.

I think I understand the rationale here. Currently, an application is running full speed even when it is out of sight from the user. This means that flash applications running on background tabs might eat up CPU without any real reason for it. Since Flash has been taking a lot of flak for this lately I can see how they are eager on improving this. The general idea behind this is sound.

However, my problem with this (and other companies as well)  is that you are breaking backwards compatibility. The throttling affects all timers and event handling. Any type of Flash application that uses multiple windows might use LocalConnection to communicate between the windows/applications. After all, that’s what it’s there for. If any of the participating applications are minimized or hidden, they will almost stop producing/consuming since they are throttled down to 2 FPS.

What is even worse is that you get no notification when this occurs. There are no callbacks or events triggered. Suddenly your application might be running at a 30th of the default speed and you will not be told about this. There is currently no option to avoid being throttled either. To me this is not acceptable if I am developing RIA:s. Imagine writing a desktop application in C++ where your timers suddenly could jump down from 60 FPS to 2 FPS. Without a callback. How would that go with the developer community?

Can this be fixed?

I think so. If Adobe only adds an opt out option for an application I think it would be fine. The default behavior could still be the throttled solution, which would probably work in 90+% of the Flash applications out there. For the freaks like us that are relying on a stable timer and LocalConnection we could explicitly say that we want full FPS even when hidden.

The argument that this could be abused is moot in my opinion. This is the current behavior so you are not making something worse even if everyone decides to opt out from throttling. Besides, what would be the motives for people to ‘abuse’ this behavior? Some evil scheme to waste CPU cycles on people’s computers?

But until then?

If you application is running into problems because of the throttling, there are some things you can try to make things better.

1. Loop a silent MP3 in your applications. Yes, I am serious. This will ramp up the FPS from 2 to 8. Still not much, but four times faster.

2. For LocalConnections you can run a separate LocalConnections per client (if applicable). This will allow you to send more data per tick. *

3. Batch data over LocalConnections. Aggregate as much as you can between ticks and then send it as an Array. Pack it up on the other side.

4. Set the parameter ‘wmode’ to ‘opaque’. This will in theory stop the timer from getting clocked down. Seems to be working for some, but it may depend on your use-case.

Remember that when your ticks go down you need to try and perform as much work as possible for each tick. Of course, this is a bit against the design principles for an asynchronous framework, but hey, that’s what happens when you start to nerf the framerate.

* Edit: This does not seem to be possible. The routing seems to be executed outside the LocalConnection, meaning that all events sent will be dispatched sequentially in a throttled manner to all recipients. Ergo, if you have one broker and four clients (think online poker game with one lobby and four tables) then for the 2 FPS case each client will receive a maximum of 1 event every two seconds. Yikes.

Fredrik Johansson is a founder and CEO of Cubeia Ltd.

You can contact him at: fredrik.johansson(at)cubeia.com

Firebase Lobby and Bandwidth

Thursday, April 1st, 2010 by fredrik

Upon popular demand I have made an analysis of the bandwidth requirements for running the Cubeia Poker on Firebase with the lobby. The scope was to test 8 000 simulated poker users on a 4-way cluster where every user is also subscribing to the entire lobby tree (i.e. all tables). The values of interest are external and internal bandwidth usages.

This somewhat technical document can be found here.

Problems with Comments + Flash

Wednesday, February 10th, 2010 by larsan

For some reason I can’t seem to comment at the moment. So if you’re experiencing problems, please bear with us.

In the last post, netsql asked about action script support (as upposed to Flex) for Firebase, and I’ll post my answer here for the time being: Good point, it should be documented. As far as I know, but I’m no Flash coder, the API is the same. So you should be able to download it and then use the Flex examples to find your way.

Drop me a line (lars.j.nilsson at cubeia dot com) and I’l let you know when we have something up on the wiki. Otherwise just hang around, we’ll get it updated in the next few days.

Update: Oh, apparently commenting is on again.

Behold the Site!

Friday, February 13th, 2009 by larsan

After a few years of ‘who care about the looks’ mentality, we now have redesigned the entire website. The system is still Joomla, but now the template is ‘HiveMind’ from the excellent RocketTheme.com. Really good stuff!

So… What do you think?