4 ms·
The goal is not to replace databases altogether. The goal is to solve some particular problems very well. Last time I used this approach, for example, we mirror
by wpietri 15y ago
The goal is not to replace databases altogether. The goal is to solve some particular problems very well. Last time I used this approach, for example, we mirrored a bunch of data in a traditional SQL store for reporting and ad-hoc querying, things that databases are great at.
In my view, direct access to data decoupled from application code is a bug, not a feature. With multiple code bases touching the same data, schema improvements become nearly impossible.
I also think data integrity is easier to maintain with a system like this. SQL constraints don't allow me to express nearly as much about data integrity as I can in code. Sure, I could use stored procedures, but if I'm going to write code somewhere, I'd rather it be in my app.
- huherto 15y ago"With multiple code bases touching the same data, schema improvements become nearly impossible." Few companies have procedures in place that allow this; but it is possible if you have the right procedures.
- wpietri 15y agoSure, but the problem becomes harder the larger you get. Look at almost any Internet-wide deployment, though, and you see the alternative: isolate database schemas behind APIs, and rev APIs and schemas separately, as the situation demands.
- kfool 15y agoIsolating databases behind APIs and rev-ing API+schema separately is not enough. When the schema changes, data must be transformed to match the new schema version. As you point out this takes too long with a large database, and it doesn't account for data consistency. We have been working on building what we hope are the procedures for this with ChronicDB (http://chronincdb.com http://chronincdb.com). But it turned out harder than it seems, and we are not sure it will quite work out. We'd welcome feedback.
- jeffdavis 15y ago"I also think data integrity is easier to maintain with a system like this." If you are in the middle of a transaction and you realize that some constraint is being violated, how do you roll it back without interfering with the other transactions?
- wpietri 15y agoI can't speak to all systems like this, but the Prevayler approach is pretty straightforward. Most importantly, there are no simultaneous transactions: changes happen one at a time. That seems crazy if you're used to dealing with disk-backed databases, but if everything is hot in RAM, then it's not a problem. In that context, it's pretty easy: when you start executing a change you verify all your constraints before doing anything.
- jeffdavis 15y ago"Most importantly, there are no simultaneous transactions... but if everything is hot in RAM, then it's not a problem" Uh, OK. So, you're happy with single-core boxes then, I take it? Actually, you're regressing to even before that, when there was no pre-emptive multitasking. When the program is done doing something, it yields control to some other task. Also, I'd like to point out that just because you aren't explicitly doing I/O doesn't mean that you aren't doing I/O. The OS might have paged out some stale data (quite likely, since you aren't managing I/O yourself), and you might be holding the giant lock while it's paging it in. "I can't speak to all systems like this, but the Prevayler approach is pretty straightforward." I just want to clarify: so when you encounter a problem, you do some rollback, which automatically moves the state to the last snapshot and rolls forward to the previous transaction, right? No manual steps? I hope you have a recent snapshot or that will be a long wait (while holding the big lock, I might add).
- wpietri 15y ago> Uh, OK. So, you're happy with single-core boxes then, I take it? Not at all. You use only one core for the core execution of write transactions, but that's a small part of any real system. All cores can read simultaneously. All cores can also do all sorts of other work, including preparing transactions to execute, deserialization of requests, rendering responses, logging, and anything else your app needs to get up to. The limit is also one core per transactional domain. If you can split your data up into lumps between which you never need transactions, you can happily run one core on each. > Also, I'd like to point out that just because you aren't explicitly doing I/O doesn't mean that you aren't doing I/O. Actually, it does explicitly do I/O. You do it just before every command executes. > The OS might have paged out some stale data. I guess that's possible, which would indeed cause a momentary pause, but this approach is typically used with dedicated servers and plenty of RAM, so it's never been a problem in practice for me. > I just want to clarify: so when you encounter a problem, you do some rollback, which automatically moves the state to the last snapshot and rolls forward to the previous transaction, right? You mean a bug in our code that causes a problem? Depends, on the system, I suppose. Prevayler had an automatic rollback. It just kept two copies of the data model in RAM; if a transaction blew up it would throw out the possibly tainted one. But there are a number of ways to solve this, so I don't advocate anything in particular. Other than heavy unit testing, so that things don't blow up much.
- eftpotrm 15y agoI also think data integrity is easier to maintain with a system like this. SQL constraints don't allow me to express nearly as much about data integrity as I can in code. Sure, I could use stored procedures, but if I'm going to write code somewhere, I'd rather it be in my app. Surely I could just as easily say 'Sure, I could use a data access layer in my app but if I'm writing a multi-app database, I'd rather the database enforced its own integrity.'? Nothing's the perfect tool for every job, but I certainly think stored procedures have their place and have the power to handle the bulk of tasks.
- wpietri 15y agoYes, you can definitely do it either way. Years ago as a demo a friend built the heart of a financial exchange in stored procedures. It was very fast, and very reliable. But the same is true about the LMAX system that Fowler describes. Personally, though, I'd much rather do my important coding in a real programming language. Better tools, more libraries, bigger communities, and no vendor lock-in.
- moheeb 15y agoEver hear of ANSI SQL?
- eeperson 15y agoWhich is not turing complete. You need database specific extensions to get that. Edit: Also, not all databases follow the standard very closely
- prodigal_erik 15y agoAren't vendors finally starting to abandon their proprietary crap in favor of SQL/PSM?
- eeperson 15y agoInteresting, I didn't know about SQL/PSM. Although judging by this: http://en.wikipedia.org/wiki/SQL#Procedural_extensions http://en.wikipedia.org/wiki/SQL#Procedural_extensions It looks like a lot of vendors still only support propriatary extensions.
- anamax 15y ago> In my view, direct access to data decoupled from application code is a bug, not a feature. With multiple code bases touching the same data, schema improvements become nearly impossible. It's unclear that multiple applications with direct access to said data make schema improvements any easier. The obvious solution, copying the data for applications that are using the new schema, pretty much guarantees that one or more of the copies are wrong. > I also think data integrity is easier to maintain with a system like this. SQL constraints don't allow me to express nearly as much about data integrity as I can in code. Sure, I could use stored procedures, but if I'm going to write code somewhere, I'd rather it be in my app. How do you guarantee that all of the apps that touch that data use the current version of said code? Code normalization is as important as data normalization.
- wpietri 15y ago> How do you guarantee that all of the apps that touch that data use the current version of said code? In a NoDB app? It's very easy: only one code base ever directly touches the data, because the data lives in the RAM allocated to the app. You give external access via an API, so integrity is very easy to enforce.
- gaius 15y agoCongratulations, you have reinvented the integrity constraint! Except IBM have been working on this for 40 years, making it reliable and performant. I have yet to see anyone roll their own data integrity layer that comes anywhere close to the major vendors.
- kfool 15y agoGood point. With databases distributing data in-memory across machines, shared memory becomes the database. Don't be surprised if Arc runs HackerNews on distributed memory some day... But one has to wonder, what happens when you need to upgrade the app? Shutting down the process and destroying the memory image doesn't seem like the best option: - First, it disrupts connected applications since the process is killed, introducing downtime. - Second, when starting up again in say version 2, the data that will be loaded in memory still needs to be transformed in the format expected by version 2. This transformation can take time on large data, introducing further downtime. The challenge would be to eliminate this downtime by combining a solution for both client disruption and state transfer. A data abstraction like a database using SQL can simplify such a solution.