Live data from Hacker News

Why Uber Engineering Switched from Postgres to MySQL

eng.uber.com

171–180 of 306 posts

Re: Why Uber Engineering Switched from Postgres to MySQL

#171
post #91

Earlier quoted context omitted.

> It sounds like Uber is using MySQL as just a data bucket with primary keys They have a couple posts about "Schemaless", but I still don't understand why they used MySQL as the data store instead of something like Cassandra. ( https://eng.uber.com/schemaless-part-one/ ) From that post it looks like they basically built a no-sql database on top of a relational database. The only reason given was operational trust ( "…

Operating Cassandra at the scale that Uber is going to require is going to be painful and as operationally draining as MySQL if not more. There are really not a large number of options here anymore with the departure of FoundationDB from the market. CockroachDB might be an option in a few years, though I'm still confused why they are moving towards a SQL-ish vs key-value interface...

What dbs would you suggest in their scale ? that are easier operationally than cassandra ?

Re: Why Uber Engineering Switched from Postgres to MySQL

#172
We've hit a lot of the same fundamental limits scaling PostgreSQL at Heap. Ultimately, I think a lot of the cases cited here in which PostgreSQL is "slower" are actually cases in which it does the Right Thing to protect your data and MySQL takes a shortcut.

Our solution has been to build a distribution layer that makes our product performant at scale, rather than sacrificing data quality. We use CitusDB for the reads and an in-house system for the writes and distributed systems operations. We have never had a problem with data corruption in PostgreSQL, aside from one or two cases early on in which we made operational mistakes.

With proper tuning and some amount of durability-via-replication, we've been able to get great results, and that's supporting ad hoc analytical reads. (For example, you can blunt a lot of the WAL headaches listed here with asynchronous commit.)

Re: Why Uber Engineering Switched from Postgres to MySQL

#173
post #162

Earlier quoted context omitted.

True, but really your local MTA is just acting like a specialized queue, since the first thing it will do is send the message to your relay.

Yes, the whole point is to avoid building your own queue where a ready-made, purpose-made solution already exists.

Well there are pros and cons. If you have already have a queue structure set up in your environment, it may not be a good idea to have to maintain a second queue structure in the form of a bunch of local MTAs. You'll need monitoring (how many messages are queued in each local MTA?) and a way to keep those MTAs up to date.

If you just put an item in to a queue, and then have a specific cluster of machines that does nothing but grab items from that queue and push them through an email infrastructure, then it'll be a lot easier to maintain.

Re: Why Uber Engineering Switched from Postgres to MySQL

#174
post #161

Why did they not consider Oracle or MS SQL Server? They can afford the licensing and both have numerous replication technologies to choose from.

Oracle ??? Let's start: - No transactions for DDL changes. - Oldschool commandline client. auto commit disabled by default. no history. - Weird sql syntax + semantics. f.e. null == empty string.

I'd add

- Oracle InstantClient SDK needs an Oracle account to download and is closed source, and is not available as a package for anything except rpm-based distros

- getting it to run with PHP is a major PITA, once again due to the above-mentioned issues

- Holy f..ing cow, why does it translate everything down to ASCII by default instead of returning raw bytes?

- It's expensive as f..k

- Try to run a query using InstantClient with a ; at the end, it will barf

- DID I MENTION IT CANNOT DO A SIMPLE LIMIT AFTER AN ORDER BY?! (at least not until 12.1, which was released in 2013; due to various issues, one including the pricing, I have seen multiple orgs running way older versions. But come on, over 30 years with only ROWNUM?!)

Re: Why Uber Engineering Switched from Postgres to MySQL

#175
post #119
post #110

Earlier quoted context omitted.

Justify that with actual math, please? I don't think you know how computers (processors, bus, memory access, etc) work. How exactly do you think an RDBMS can query an index at a hundred billion rows per second?

Illniyar is right, a b-tree with a branching factor of 100 can index 100M rows in 4 levels. Even with the index on a spinning disk, should have no trouble coming in well under 100ms.

Indexes like this are also typically in memory to begin with, making it even faster, since you only have to find the actual record on disk.

Even better, if you only need one field from the record, and it's part of a compound index, you can frequently return the data from just the indexes; no disk seeks required. Small tip with InnoDB on MySQL - any non-primary key index is automatically a compound index with the primary key.

Re: Why Uber Engineering Switched from Postgres to MySQL

#177

Earlier quoted context omitted.

I was wondering how could that happen? It sounds like someone is trying to do two things in parallel. I would expect def my_view(request): try: receipt = generate_receipt(...) receipt.send_email(...) except SomeKindOfEmailError as e: # okay do something else and this should be synchronous and thus blocking. So to not block, they either wrote co-routines (asynchronous) or execute things in parallel. Have I interpreted…

Open db connection get data for receipt generate receipt send email write success to database close connection To a junior programmer this would probably look reasonable, and to be fair, it takes some experience and getting burned, or good training, to know it is not.

I was about to argue but then I realized: I've been working in the MS world for so long, I forgot that not everybody has connection pools.

The MS recommendation is the opposite: get the connection early, finish with it late, let us worry about the "real" connection. I've been working on multi-TB databases like that, with hundreds of concurrent requests, and never had problems.

Re: Why Uber Engineering Switched from Postgres to MySQL

#178
post #157

> MySQL supports multiple different replication modes: > Statement-based replication replicates logical SQL statements (e.g., it would literally replicate literal statements such as: UPDATE users SET birth_year=770 WHERE id = 4) Postgres has that too (using a 3rd party tool, but it's an officially supported tool). We were using it on reddit 10 years ago. It caused a lot of problems. I wouldn't call that an advantage…

Experience with Mysql replication (even simple master/slave) leads me to believe Uber is going to have some rather nasty surprises at some point.

MySQL has had solid and flexible replication options for a long time. Postgres has only just started to catch up in the last couple of years.

Don't get me wrong, I would generally choose Postgres over MySQL for an RDBMS with replication requirements these days, but I'm not sure I would have made that same descion a few years ago.

There are valid reasons that long established companies such as Google, Twitter, Facebook and countless others chose MySQL as their primary data store.

Re: Why Uber Engineering Switched from Postgres to MySQL

#179
Great write-up. A few observations:

1. The encoding and translation schemes of Postgres and mySQL/InnoDB are well described in the blog post, and I would also agree that InnoDB’s design is, all things considered, better for all the reasons outlined in the post.

2. I don’t understand why anyone still uses lseek() followed by read()/write() and not pread()/pwrite() syscalls. It’s trivial to replace the pair of calls with one. Aerospike is another datastore that resorts to pairs of seek/red-write instead of pread/pwrite calls.

3. Process/connection model makes no real sense nowadays - although to be fair, there is, today, practically almost no difference in terms of footprint between OS threads and OS processes (other than memory and FDs sharing semantics, they are practically the same). It’s still more appropriate to use threads (although I ‘d argue maintaining a pool of threads for processing requests and one/few threads for multiplexing network I/O is the better choice).

4. ALTER TABLE is obviously a pain point with mySQL, although I am not really sure many users with large datasets care; they probably figured out long ago it’s going to be an issue and they designed and expanded accordingly. It’s also a relatively rare operation. That said, other than using mySQL (or any other RDBMS) to build the data plane for an elaborate, distributed KV store, one should consider Salesforce’s approach too. Their tables have some 50 or so columns, and the column names are generic (e.g column_0, column_1, … ). They have a registry where they assign column indices (e.g column_0) to a specific high-level entity type (e.g customer title, or price), and whenever they need to query, they just translate from the high level entity to the actual column names and it works. They also, IIRC, use other tables to index those columns (e.g such an index table can have just 3 columns, table id, column index, value) and they consult that index when needed (FriendFeed did something similar).

5. Cassandra should have no problem supporting the operations and semantics of Shemaless ass described in their blog posts. However, given they already operate it in production, they probably considered it and decided against it.

Re: Why Uber Engineering Switched from Postgres to MySQL

#180
post #161

Why did they not consider Oracle or MS SQL Server? They can afford the licensing and both have numerous replication technologies to choose from.

Oracle ??? Let's start: - No transactions for DDL changes. - Oldschool commandline client. auto commit disabled by default. no history. - Weird sql syntax + semantics. f.e. null == empty string.

I'm with you on all of your points except auto-commit: having it off by default is much better, it forces you to explicitly commit when you change data and thus think if you really want to persist the changes.
Post reply on HN