News for hackers. Stuff that matters.
Re:Twilio incident and Redis by eblume on Wednesday July 24, 2013 @06:18PM (#6099471)
It's good to see Twilio post this! That being said - yeah, I really am concerned that Twilio is using an ephemeral database to store such important data. Why not simply use Postgres? Is Twilio really making so many transactions per second that Postgres won't scale?
Re:Twilio incident and Redis by RobSpectre on Wednesday July 24, 2013 @06:26PM (#6099517)
Totally agree. Need to clear up a developing misconception - Redis does not serve as the primary store for the account balance of Twilio's customers. The billing system uses a double bookkeeping model common to many high volume designs with Redis as the in-flight data store (e.g. when a call or SMS message is created) with the transaction also stored independently to an RDBMS post-flight (e.g. when a call or SMS message is completed).

Clearly however our implementation failed dangerously and did not recover in a manner that meets our customers' expectations. Totally get how such a misconception would occur from a cursory read of the incident report - just need to be clear.

Re:Twilio incident and Redis by PommeDeTerre on Wednesday July 24, 2013 @07:02PM (#6099729)
Is there actually a legitimate performance or scalability need to incorporate a NoSQL database in this case?

Ever since NoSQL databases started receiving a lot of hype a few years back, I've witnessed a number of teams use them without any real justification. They'll build unnecessarily complex systems using one or more NoSQL database systems, all while a relational database would be more than sufficient for their needs.

In several of these cases, some of the developers have been quite adamant that these NoSQL databases are essential. Then we rip them out, usually because they've been causing problems like described in this case. It quickly becomes obvious that they were never needed in the first place, and won't be needed even in the face of significantly increased load.

Re:Twilio incident and Redis by KirinDave on Wednesday July 24, 2013 @08:41PM (#6100175)
> Is there actually a legitimate performance or scalability need to incorporate a NoSQL database in this case?

Usually the most compelling reason not to use a traditional SQL database is that they're expensive to field in distributed environments and require specialist engineers to support when you get out into the weeds.

But I submit it's a category error to call Redis a "NoSQL database." It was also a category error to put data that needs to be redundant and durable into a storage system that is really specialized for high volume but low-reliability cache work.

I mean, seriously. Minimum viable PostgresSQL deploy in EC2 is pretty damn expensive, but you may not have enough cash on hand to buy your own hardware and pay to put it in a "real datacenter." If you can find something cheaper and you're not even seed funded yet because no one funds your social product until you have 100k users, you're probably more likely to actually make it to where you can afford a different database by just using Redis. It's called "technical debt" and we accrue it both bitterly and often willingly.

Re:Twilio incident and Redis by AYBABTME on Wednesday July 24, 2013 @07:24PM (#6099862)
Some problems are better solved with key-value stores than with relational databases. It depends on the data model you need to map.

Lot of people use relational databases as a big key value store, when really they should use a key value store. It's not necessarily about scalability or performance. =)

Re:Twilio incident and Redis by aidos on Wednesday July 24, 2013 @07:35PM (#6099918)
Yes. And Redis provides an interesting model with very specific performance characteristics depending on how you choose to store your data in each case. If you haven't worked with Redis it might be hard to appreciate how it's a bit more than just a key-value store and how it's a different tool from a relational db.
Re:Twilio incident and Redis by encoderer on Wednesday July 24, 2013 @09:58PM (#6100487)
I think you're making a number of mistakes in judgement here. Most importantly, you're conflating NoSQL with "not as reliable." As if there's no difference between Cassandra, HBase, Redis, etc. They're just "nosql" and "not needed" to you. That just seems highly ignorant of the relative merits of each database.

And similarly, the attitude that a RDBMS is the right and proper data store, that all data should rightly prefer to live in an RDBMS aside from the loftiest heights of scalability.

Finally, the assertion that using a key-value or column-based datastore is going to lead to an "unnecessarily complex" design.

I'd not be surprised to find you disagree, but if we were working together on the same team, these are some things I'd try to work with you on.

Re:Twilio incident and Redis by fusiongyro on Thursday July 25, 2013 @01:25AM (#6101067)
I can't speak for the person you're replying to, but I would like to point out that RDBMSes are built on theory designed explicitly to handle general data problems. Situations for which the relational model is not a good fit are almost by definition special cases.

Similarly, while it is wise not to lump all of the non-SQL/non-relational databases together, to say that the bulk of them share a common obsession with scalability is not much of a reach. After all, we're not talking about Neo4J, FramerD, MetaKit, etc. We're talking about young systems that were born out of frustration with scalability issues. It's true that they all have different tradeoffs, strengths and weaknesses, but one significant advantage of Postgres is that it does so well in such a variety of situations. Maybe it isn't perfect for every scenario, but it's pretty good for most scenarios. This is partly an inherent advantage of age, and partly the benefit of a sound theoretical foundation. A big thing I dislike about the current crop of NoSQL databases is that you are expected to learn a great deal about their inner workings to make an informed decision about whether or not to use them. MongoDB really epitomizes this. But this is a pretty lazy complaint compared to random data loss and insane defaults (early days of Mongo), and I have to give you that.

Your position sounds quite reasonable compared to the one I've been primed by, but it's going to be a few more years before these databases mature to the point I'd consider one a reasonable first choice for a generic database. I don't draw the line quite as far as the GP—sometimes you have a special case and you need special tools—but I can certainly empathize with questioning the wisdom of making a distributed non-relational database the primary store for a low-load, classic RDBMS problem. But Twilio has come forward and agreed with that position and denying that they do that, so the spark for this flamewar is conjecture. While people have come forward to defend such a configuration, few seem to be endorsing it by using it themselves. This says something about the reasonableness of the idea.

Re:Twilio incident and Redis by hhuuggoo on Thursday July 25, 2013 @10:03AM (#6102457)
I use nosql stores for the same reason that I use a dynamically typed language (python) I like the flexibility and agility. I don't use nosql stores for performance
Re:Twilio incident and Redis by threeseed on Wednesday July 24, 2013 @07:42PM (#6099950)
No offence but attitudes like this are the worst. If we all took your advice we would all be still using punch cards or writing everything in assembler. Sometimes you don't need a clear justification to use newer technologies. Perhaps developers just want to experience the significant developer productivity that comes with using many of the NoSQL databases.

Also might be worth dropping the whole "SQL is better" insinuation. We have seen some pretty major data loss bugs in PostgreSQL and MySQL recently.

Re:Twilio incident and Redis by fusiongyro on Thursday July 25, 2013 @12:55AM (#6100990)
What major data loss bugs have you heard about "recently" in Postgres and MySQL? There was a significant security problem in Postgres that was recently fixed, but I haven't heard of any recent data loss bug. Even MySQL has been doing well on this point lately.
Re:Twilio incident and Redis by EugeneOZ on Thursday July 25, 2013 @01:50PM (#6103781)
In this case data was corrupted ONLY by humans mistake, it's not Redis fault (even author of article wrote it).
Re:Twilio incident and Redis by fusiongyro on Thursday July 25, 2013 @02:51PM (#6104223)
I'm not accusing Redis of losing data, I'm correcting a factual error about the reliability of MySQL and Postgres.
Re:Twilio incident and Redis by PommeDeTerre on Wednesday July 24, 2013 @08:42PM (#6100182)
Billing systems are not to be taken lightly, namely because money is inherently involved.

When developing such systems, it is irresponsible to use new, unproven technologies without justification.

When developing such systems, it is irresponsible to trade off the reliability and safety of the system for some "developer productivity".

Such irresponsibility is just not acceptable. Failures due to such irresponsibility should not be tolerated, either.

Re:Twilio incident and Redis by jessaustin on Wednesday July 24, 2013 @10:21PM (#6100555)
Failures due to such irresponsibility should not be tolerated, either.

I appreciate that you are very committed to reliability. I also have worked on (telecom) billing systems. However, what are you suggesting here? Should all Twilio's customers find another provider? (Do you have a suggestion?) Should they just not use a service like Twilio's? Should Twilio quadruple their prices so they can throw up enough hardware to do all this in postgres? Should we all fly over to Sicily to protest outside antirez's house?

Incidentally, in the late '90s I sat in on a few sales efforts in which Lucent pushed their "Datablitz" in-memory database for mediation and billing of call records. So, it's not as though nothing similar to this has ever been done.

Re:Twilio incident and Redis by taf2 on Wednesday July 24, 2013 @09:40PM (#6100418)
money can be refunded... we're not talking about a life - or a human life we're just talking about software. Reading how Twilio was using redis it sounds very reasonable (fsync). I've seen MySQL servers melt under extreme load running on very high end servers so if you're saying that somehow having had SQL in this case would have saved them... well... maybe you're right... but I wasn't there were you?

I believe the engineers at Twilio are building and have built a platform to handle a scale that is going to continue to reach further than many traditional models will scale. It makes sense to me that they would need to look for in memory systems to push the limits - They are fsync'ing immediately - so while it's in memory for a read it's disk for writes so that sounds pretty safe to me... Also, a lot of people use Redis now, so I definitely wouldn't say it's unproven, that is as others have said like saying we should still be using typewriters to put ink on paper because it's "proven"... I'd answer that with... "good luck with that".

And at the end of the day - "the shit will hit the fan" and it did...

the team did great and we're all thankful.

Re:Twilio incident and Redis by PommeDeTerre on Wednesday July 24, 2013 @10:33PM (#6100592)
Just because human lives aren't necessarily at stake it doesn't mean that poor (in my opinion) software system designs should be tolerated.

And when we talk about "relational databases", we basically never mean MySQL. I'm not even sure why you'd bother to bring it up, given its poor reputation, its lack of proper functionality in some cases, and the many other (and far better) alternatives.

As for scalability, some other commenter here posted a link to a twitter comment describing the scale in this case: https://twitter.com/dN0t/status/360119871318659074

It clearly states "tens of thousands" of transactions per second. That is well within the capabilities of the lower-end database systems on modern, low-end server hardware. Twilio will require a huge amount of growth just to reach the point where higher end database systems and hardware become appropriate, never mind "a scale that is going to continue to reach further than many traditional models will scale".

Running into significant billing issues due to a likely unnecessary use (in my opinion) of a NoSQL database while still at a relatively small scale is not something that a team should be commended for, and nobody should be "thankful" that the incident did happen.

Re:Twilio incident and Redis by defen on Thursday July 25, 2013 @01:53AM (#6101125)
The equivalent failure with PostgreSQL would be to update kernel.shmmax with a call to sysctl, and then forget to update /etc/sysctl.conf. Then if the machine reboots PostgreSQL will fail to start because it can't allocate enough memory. It mostly wasn't a redis problem as far as I can tell. That said, Twilio is probably at a big enough scale where they can afford to hire a couple full-time admins to deal with PostgreSQL.
Re:Twilio incident and Redis by pbreit on Wednesday July 24, 2013 @09:13PM (#6100315)
Understood. But maybe billing isn't the best place to experiment?
Re:Twilio incident and Redis by badclient on Wednesday July 24, 2013 @08:39PM (#6100165)
How are NoSql databases more productive than SQL?
Re:Twilio incident and Redis by marshray on Wednesday July 24, 2013 @10:20PM (#6100553)
Regardlesss, something about the redis query returning a zero balance was triggering bad behavior in the billing system.

Also, reading between the lines in the incident report made it sound as if there might have been multiple teams involved in the troubleshooting and not communicating perfectly. For example, were the redis admins informed that customers had been getting billed repeatedly when the decision was made to restart the billing system? Did they have access to the billing system logs which might have contained errors related to redis being read-only?

All in all, big props to Twilio for starting to get customer accounts credited back within 11 hours of the first trouble and even more for their wonderful open disclosure.

Re:Twilio incident and Redis by justincormack on Wednesday July 24, 2013 @06:44PM (#6099611)
But it does appear (if I understand correctly) that sometimes you used Redis as if it was the system of record rather than checking the actual one, hence the rebilling?
Re:Twilio incident and Redis by newman314 on Wednesday July 24, 2013 @09:23PM (#6100349)
So what happens when there is a failed transaction mid-flight? It's already in redis but not in RDBMS. How do you rollback then?
Re:Twilio incident and Redis by dkulchenko on Wednesday July 24, 2013 @06:38PM (#6099578)
Redis is not an ephemeral database when used in Twilio's configuration. When configured with an AOF with fsync set to 'always', Redis will be as durable if not more durable than postgres and the like.
Re:Twilio incident and Redis by pjscott on Wednesday July 24, 2013 @07:28PM (#6099879)
To expand on that a bit: when redis is in AOF mode, all write commands are appended to a journal file. When fsync is set to 'always', this journal file is fsynced on every write.

Redis has a reputation as an "ephemeral database", because it's usually used as one, but there's nothing inherently ephemeral about it. This isn't magic; it's just file I/O.

Re:Twilio incident and Redis by recuter on Wednesday July 24, 2013 @07:27PM (#6099868)
I understand how the AOF can be considered similar to a postgres WAL file but what makes you say its even more durable?
Re:Twilio incident and Redis by count on Wednesday July 24, 2013 @08:54PM (#6100229)
Forced fsync on every write.
Re:Twilio incident and Redis by theatrus2 on Wednesday July 24, 2013 @11:57PM (#6100825)
Like a WAL file.
Re:Twilio incident and Redis by pjscott on Thursday July 25, 2013 @12:39AM (#6100950)
(In its default configuration; there are some unsafe speedups you can do.)
Re:Twilio incident and Redis by EugeneOZ on Thursday July 25, 2013 @03:37AM (#6101325)
Ability to make RDB snapshots additionally.
Re:Twilio incident and Redis by VladRussian2 on Wednesday July 24, 2013 @07:25PM (#6099865)
>Redis will be as durable if not more durable than postgres and the like

guessing by your username where you may be from, you may be aware that freshness... err... durability comes in only one grade - first grade :)

Re:Twilio incident and Redis by banachtarski on Wednesday July 24, 2013 @06:42PM (#6099599)
Not twilio, not ephemeral, postgres also has durability issues in the many configurations, your durability is still only as good your kernel's disk controller, tps has very little to do with the decision to use redis or postgres.
Re:Twilio incident and Redis by michaelmior on Wednesday July 24, 2013 @06:22PM (#6099494)
This wasn't posted by Twilio, but the creator of Redis.
Re:Twilio incident and Redis by aidos on Wednesday July 24, 2013 @07:30PM (#6099897)
As others have said, Redis is resilient in this configuration and by no mean ephemeral.

It's worth nothing from the original Twilio post "This cluster is configured with a single master and multiple slaves distributed across data-centers for resiliency in the event of a host or data-center failure". Ironically it may well be that not having the slaves at all could have prevented the outage.

I've seen other scenarios in the past where having a (mysql) master-slave arrangement has caused an outage. Root cause was bad configuration and a bug in the app code but had there been no slaves, there wouldn't have been an outage.

Just goes to show that it always pays to think carefully about the complexity you introduce into systems.

Re:Twilio incident and Redis by StavrosK on Wednesday July 24, 2013 @06:29PM (#6099532)
Well, it's not "ephemeral". I don't consider it as durable as postgres either, but I am hard-pressed to find a reason why I think that, which is usually an indication of a faith-based, rather than fact-based, opinion.
Re:Twilio incident and Redis by lifeisstillgood on Wednesday July 24, 2013 @06:46PM (#6099626)
Reasons: longevity

Postgres has had it's failures under weird confluences of circumstances - and learnt from them a decade or more ago.

I would like to see Twilio standby their stack choices, invest time and effort and sponsorship of redis so that in a decade or two people will be taking it on faith that redis is bullet proof (well the combined postgredis datastore:-)

Re:Twilio incident and Redis by StavrosK on Wednesday July 24, 2013 @07:15PM (#6099814)
The append-only file just... well... appends every command to a file. That's pretty solid, especially on journaled filesystems, so I can't find any durability-related reason why it shouldn't be used.
Re:Twilio incident and Redis by nknighthb on Wednesday July 24, 2013 @07:48PM (#6099972)
The only durability "problems" I've ever been able to come up with for Redis involve human error as a key component, like what Twilio experienced here with the AOF/RDB mixup.

The new CONFIG REWRITE command makes it easier to avoid, but it would be nice if it were harder to get this wrong in the first place.

What it definitely isn't is fully ACIDic, though for some workloads you can get close if you use it very, very carefully.

Re:Twilio incident and Redis by bigiain on Wednesday July 24, 2013 @07:47PM (#6099970)
"Is Twilio really making so many transactions per second that Postgres won't scale?"

Telco billing systems are (or at least used to be) one of the busiest uses of databases. When you're billing in increments of only a few cents per transaction (typical for outgoing SMS), the volume of transactions for any reasonable amount of money can be _huge_.

I don't know how soon Twilio are going to get within an order of magnitude or two of AT&T or Verizon, but I'd hazard a guess that their transactional billing database is _very_ busy by just about _anybodies_ standards.

Re:Twilio incident and Redis by aphyr on Wednesday July 24, 2013 @09:35PM (#6100399)
Twilio's write volume is on the order of tens of thousands of writes per second. https://twitter.com/dN0t/status/360119871318659074?p=p
Re:Twilio incident and Redis by pbreit on Wednesday July 24, 2013 @07:58PM (#6100009)
But this issue seemed to be with processing payments vs. metering usage, quite a difference in volume.
Re:Twilio incident and Redis by bigiain on Wednesday July 24, 2013 @08:29PM (#6100128)
I haven't re-read the article, but if I recall correctly the Redis in-memory data was being used to keep a working copy of the current account balance (not the canonical accounting/bookkeeping version) and it was the results of calculations based on the Redis stored data that was triggering the payment processing. So I think it _was_ a problem with a "metering usage" scale system, which cascaded into the payment processing system working as intended, but with erroneous data.
Re:Twilio incident and Redis by vertis on Thursday July 25, 2013 @05:31AM (#6101611)
It has now been noted that Redis is not the primary store of this information.