Tuesday, April 24, 2012

More on DynamoDB - The good part!

In a previous post on DynamoDB, I told you we were in the process of migrating to DDB and from MongoDB for our largest datastore. Now, we have moved a bit further on this and we, including myself, has pretty positive view on DDB, it really is a viable MongoDB alternative if you can live with the limitations. That said, there are many limitations, but I would like to put this differently. I would say this is an opportunity to simplify and get real good performance from your base level data, and combine it with other technologies where appropriate.

I wouldn't think that any serious application that use a database could live with DynamoDB only, unless the application developers were prepared to do just about everything database related, beyond the most simple, themselves. For example, you might need a secondary index, DDB doesn't provide you with them, so what you could do is use another DDB table as an index into the main data. Which is fine, but you have to implement it yourself, no more CREATE INDEX statement, no more ensureIndex() command and no more "the index is there so the optimizer will use it" rather "I have now an index on that previously unindexed attribute, so I rewrite my code to take advantage of it".

That said, how I would like to see DDB, and this is how we use it here at Recorded Future, is as a store for low level objects, like BLOB, pieces of text, pieces of XML, collections of keywords, you name it. Then you reference that data with an id that is looked up in some kind of supporting technology, like a free-text search engine or MySQL or both.

What we are looking at doing here at Recorded Future is to use DDB for just this kind of stuff. The supporting technologies are, in our case, MongoDB (yes, MongoDB, we have data in MongoDB today that will not work well in DDB, data that has secondary indexes on it, data that has uses more features in MongoDB etc) and Sphinx. But this may change. The database we are moving from MongoDB to DDB is just so simple and straightforward as is required to make it a good for for DDB.

And despite the limited functionality, DDB has several advantages:
  • It performs well, and I can pay for only the throughput I need. Actually, pricing is one of the intriguing aspects of DDB, that you pay for throughput, basically, not for storage, number of servers, number of users or something as arcane as that.
  • It is managed by Amazon, and Amazon seems to do a good job here.
  • DDB currently lacks any kind of backup mechanism, and as DDB isn't exposed outside the managed Amazon DDB environment, there isn't much I can do about it, so I just ignore it and tell my managers that Amazon will not allow me to back up our data (yes, I am kidding now).
  • There are several reasonable well working APIs, Ruby, Java etc that is integrated in the same Amazon APIs as the other Amazon services (the REST based API that these are built on leaves a fair bit to be desired, as does the documentation).
We are not live with DDB yet, we need to figure out a way to perform backups (as we can't get backups out of DDB, we have to find a way in out application to catch data before it enters DDB) for example, and we have coding to do, but my initial reservations regarding DDB are not as strong as they used to be, but one has to know the limitations, fave the facts and work with them. But that is life in a Cloud environment anyway.

As for the DDB pricing model, should we call that Cloud-based prising?

/Karlsson

Face the facts: There is no Big Data / Big Analytics silver bullet

We have a lot more storage space available these days, and a lot more data to work with, so Big Data and Big Analytics is getting much more mainstream now. And there are conclusions and insights you can get from that data, any data more or less, but Web data in particular brings a new dimension when combined with more traditional, domain specific data. But this data is also mostly in the shape of plain text, like your blogs, twitters, news articles and other web content. And this in turn means that to combine your organized structures sales data for 20 years with Web data, the Web data first needs to be analyzed.

Web data also brings in a new difficulty: the data is big, and it's not organized at it's core, so you can not easily aggregate or something like that to save space (and why would you want to do that?). It's not until after you have analyzed it that you know what data is interesting and what is not. And to be frank (but I am not, I'm Anders), not even then can you start to aggregate data or throw data away that isn't interesting. And in my mind, this is an mistake that has been done in all sorts of analytics, even with smaller amounts of data.

When it comes to analytics, in my mind "If you think you have all the right answers, you haven't asked all the right questions". This is an important point, analytics is a recurring activity, and the more questions you get answered, the more questions you should get. And with this in mind, how can you know what to aggregate? In particular when it comes to web content?

So, can we live with Web data not being aggregated and how do we do it? What database can support that? Oracle? MySQL? MongoDB? Vertica? And the answer is, in the same way as with analytics, you will not know when you start analyzing, and once you have started doing that, you will be even more in doubt! Which technology supports all the aspects you might need to look at? And the keyword is might!

So, how can we solve this? And my answer is: By using the right tool for the job at hand, and be prepared to combine different tools! Postgres and Oracle are great for temporal analysis, for GIS we have Oracle, MySQL and PostGIS. For handling large amounts of data with good scalability and keeping the cost down, you might want a key-value store like MongoDB or DynamoDB. To search data you might head for Sphinx or Lucene. Etc. etc.

As an example, I'd might want to look at a key-value store for my raw Web data, holding some key for easy lookup. An RDBMS for the attributes of this data. Sphinx for searching it. Sphinx and Lucene are much better tools than your average RDBMS, be it MySQL or Oracle or Whatever, and RDBMS search is different than a text search in web-data!

So the most important aspect to look at, if you ask me, is to choose technologies that can easily be combined and where different aspects of data can be served by different technologies as appropriate. And be prepared to add, remove and change technologies as you go along!

/Karlsson

Monday, April 2, 2012

Speaking at Big Data in Stockholm

I will be spaking at the conference "Reality Check: Big Data" coming up on April 26 here in Stockholm. This is all about big data in in's different shapes, and the conference is run by Swedish Computer Society and is sponsored by IDG. Read more about it here: http://www.dfkompetens.se/konferenser/kurser/1112022/index.xml

If you are there and want to talk, just catch me there, I'll be there most of the day, and my talk is in the afternoon, at 15:15.

Cheers
/Karlsson

Wednesday, March 21, 2012

Amazon DynamoDB ... Is it any good

As you might have noticed, I'm getting further away from MySQL here. This is just how things are I guess, I just do much less work with MySQL these days. The first migration was from MySQL to MongoDB, which was some time back. This was pretty successful, but note that we still have some data in MySQL, but the bulk of the data is in MongoDB right now.

Running any database on Amazon (and we run all databases on Amazon or on Amazon RDS service) may be costly, depending on how you utilize your resources. The recently announced Amazon DynamoDB is Amazons NoSQL service offering, but it is not like MongoDB with a twist, far from it. If you have read what I have written about MongoDB, I have now and then complained about the lack of functionality, but to be honest, I have learnt to live with MongoDB and it's shortcomings, and have started to like many of the JavaScript features of it (one thing I hate about it, and about JavaScript in general though, is the numeric datatype. It's just plain silly).

That said, we are now taking a shot at migrating again, this time to DynamoDB. In comparison with MongoDB, DynamoDB is incredibly simplistic, there are very few things you can do. To begin with, there is one "index" and one index only on each table. This index is either a unique hash key (that is what they call it) or a combination of a hash-key and a range-key (a unique composite key). I'll soon get into the gory details later. You can not have secondary indexes, i.e. indexes on any other attribute than the "primary key" or whatever you want to call it.

You can then read data in 1 of three ways. Simple:
  • You read a single row by unique key access. If you have a composite hey, provide both the hash-key and the range-key, else provide just the hash key.
  • You scan the whole table.
  • If you have a composite key, access by the hash-key part and scan (you may filter, but in essence, this is still a scan) on the range key.
There is nothing else you can do, and note that unless doing a full table scan, you must always provide the hash-key, i.e. if you do not know the exact hash key for the row to get, you have to do a full table scan. There is just no other way.

The supported datatypes aren't overly exciting either: Number, String and a Set of Number and String. The string type is UTF-8 and the Number is a signed 38 precision number. Other notable limits is that there is a max of 64 K per row limit, and that a scan will only scan up to a max of 1Mb of data. Note that there is no binary datatype (we have binary data in out MongoDB setup and use base64 encoding on that in DynamoDB).

Pricing is interesting. What you pay for is throughput and storage, which is pretty different from what you may be used to. Throughput may adjusted to what you need, and it's calculated in kb of row data per second, i.e. a table with rows of up to 1Kb in size that with a requirement of 10 reads per second will mean you need 10 units of read capacity (there is a similar throughput number for write capacity). Read more on pricing here.

All in all, DynamoDB still has to prove itself, and in some situations it might turn out expensive, in other situations not so. I have one major big gripe with DynamoDB, before I close for this time: DynamoDB is not Open Source, nor is it a product you can buy, except as a service from Amazon. You want to run DynamoDB on a machine in your datacenter? Forget it. This annoys the h*ll out of me!

We are still testing, but so far I am reasonably happy with DynamoDB, despite the issues listed above. The lack of tools (no, there are no DynamoDB tools. At all. No backup tool, no import / export, nothing) means that a certain amount of app development is necessary to access it, even for the simplest of things. Also, there is no Backup, but I am sure this will be fixed soon.

/Karlsson

Wednesday, March 7, 2012

Amazon RDS take two

I wrote in a previous blogpost, a few weeks ago, that we had started to migrate our MySQL databases to Amazon RDS. We have now been running this for quite a while, and so far we have not had any issues at all. The plan was to migrate even more, but this has not happened yet, as we got into another interesting migration: MongoDB to DynamoDB!

So far we have done some benchmarking, and we are pretty happy with that. DynamoDB has some interesting features, among the most interesting one is how they price it, where you pay for performance and resources used. This is not too dissimilar to what I suggested way back at a MySQL Sales conference, so maybe my head was correctly screwed on after all.

As usual, Amazon will not give much details on what they are doing, and how, but as DynamoDB is related to Cassandra, we have to assume it is an LSM-tree database. Amazon also claims that Flash / SSD storage is used for DynamoDB.

The main issue I have with DynamoDB isn't performance, I think this is an area where Amazon have done their homework. But DynamoDB is really limited in terms of functionality, there are only some simple operations available, you can have only 1 key (which may be composite, but still). There is a very limited number of datatypes, but this isn't that much of a problem for me per see (see this blog post), rather the types that are available aren't really that generic (a numeric 38-digit precsion number and a UTF-8 string), I ask where the generic variable length byte stream type is (in my mind, this is the one datatype that all databases should provide. There is hardly anything that cannot be represented as such a datatype).

Anyway, when we get furrther along with our DynamoDB testing, I'll let you know.

Cheers
/Karlsson

Saturday, February 25, 2012

Book review: "The computer boys take over"

I guess that most folk who read this blog are IT people in one way or the other. I do not expect my mother to read it, or even my wife. This is, after all, mostly about rather geeky technical computer things. But what do I do, when I am at work? I have been asked this more times than I care to remember, and I think this goes for most of you. Your significant other asks, your mum, some realtive, a guy you meet on a train or in a bar.

So what do we do, really? 50 years ago, the kind of jobs we do didn't even exist, and now most young people today can't figure out what a world without computers would be like. A large organization with 10s of thousands of employees managing all those people and all their production completely without computers? Not even thinkable these days, but way into the 1960s, computers was not something for everyone or even for every corporation, and many didn't even know what to do with them, did they have one.

So there has been an explosion not only in the number of computers, but also in the number of people, like ourselves, working with computers. And this type of rapid growth of a profession usually cause things to happen also on the sociological side of things. How do we work together? How does the rest of the work commuicate with us? How does a high-ranking manager of a large corporation feel when his skills are questioned by some dude in a t-shirt, a long beard a wearing sandals? And there is nothing he an do about it. He has to communicate, not the other way around (which might be just as well, we computer dudes mostly aren't good communicators anyway). And how does this change society as a whole?

These were some questions and issues I wanted to have some ideas of answers on, or at least some additional insight in, when I picked up "The computer boys take over" by Nathan Ensmenger (ISBN 978-0-262-05093-7). The book didn't actually turn out to be just what I expected though. As for a historic book, I usually prefer them to be largely cronological, and if the subject is broken up in smaller ones, then at least those I perfer to have these sections in some cronology. In this case, this wasn't so. Rather, this book seems like a book for students to read sections of. The different sections on the different aspects of the computerization of society and the status of the IT workes largely overlap, and the same quotes are used to support different things. Also, the book really gives little insight on the process of things, rather, certain events are exlained, and the impacts those events have, but then they are largely lost, until they pop up in another section of the book and some more is mentioned on the subject.

Don't take me wrong here, this is not a bad book and I did get lot of interesting insights, but the book was really boring to read in the sense of the organization of things, the gems were hidden here and there all over the book, with the rest filled with a lot of repetition of arguments and quotes.

I don't regret buying this book or reading it, but I feel it is not really intended to be read like I read it, front to back. Rather, it seems like this is more of a book for classes or academics, where a section of the book is read, which is not a bad things per se. The reasearch behind the book has also been extensive and ambitious is seems, with a huge section at the send of the book with footnotes, references and a comprehensive index. The index itself makes this book useful to me as a reference work. But I feel that the book could have been better with some more organization of the subject, a better cronology and some more editing.

One thing that is missing throughout the book was the international persepctive. The book is very focused on the US environment, and there are very few mentions of the effects of society and how the computer professional profession grew in other parts of the world. There are a few quotes from Maurice Wilkes, but those are so common and well known that they just could not be left out in a book like this. Like this 1946 quote from Wilkes (which proved to be more true than anyone knew at the time I think): "It had not occured to me that there was going to be any difficulty about getting programs working [...] And it was with somewhat of a shock that I realized that for the reat of my life I was going to spend a good deal of my time finding mistakes I had made in my programs."

And again. If you want to read something about the sociological influence on society and on the growth of the "computer buys" as a profession, there isn' really that much to read. So maybe this book is for you, maybe on a long flight or something. But be prepared to be a bit bored in between in interesting sections.

/Karlsson

Tuesday, February 21, 2012

Amazon RDS for MySQL - Is it any good?

We have been testiing the MySQL RDS Service from Amazon here at RF, and so far it looks good for what we use MySQL for. We don't have that much data left in MySQL though, but some of the services are still mission critical, and we have had a couple running on RDS for a week or so.

I have to say I am pretty happy so far, but there are a couple of things you should know before you get to use the services. To begin with, you don't get a proper MySQL root account, i.e. no SUPER privileges. No big deal I guess, but this means there are a few things you cannot do. I was planning to migrate off the EC2 based server to RDS by setting up the RDS service as a slave, and then switching to the RDS service, but as SUPER privilege is required for CHANGE MASTER TO, I could not do this. And before you ask: Amazon DOES support slaves among the RDS servers, but this is set up using their own methods. Easy to use, yes, but not as flexible as the real thing.

As for parameters, you can modify a bunch of them, but not all. I have to benchmark performance here eventually, but it has been sufficient for our modest MySQL needs so far, so I might not even do that. I also have to check what parameters I am allowed to modify and which I can't in some more detail also, to figure out if there is anything significant missing.

So far though, I think the conclusion is that this is a great service for people with low / medium requirements in terms of MySQL. Backup and snapshots are a breeze and are automated, cross availability zone use is also an option (not tested by me though). The server is accessed just like any other service, so you can set up Route 53 with a more reasonable name to point to it, if you wish. Which nodes can access the server is also controlled by you, both the service itself controlling what can access it, and by the usual MySQL GRANTs.

When we get more servers running on RDS, I'll let you know more.

Cheers
/Karlsson