36 ms·
In defense of simple architectures
- aadvark69 4y agoSimple architectures work well, until they don't. A good example is ye olde ruby on rails monolith. Dead simple to set up and iterate quickly, but once you reach a certain organization and/or codebase size, velocity starts to degrade exponentially
- hw 4y agoTell that to Github, Shopify, Gitlab, Zendesk etc that have been doing fine. How often do you hit ‘that certain size’ when velocity starts to degrade anyway? X works well until it doesnt… is not exactly a compelling argument. That can be said of simple and complex architectures, or just anything at all
- deterministic 4y agoComplex architectures work well, until they don’t. Fixing complex architectures is much harder than fixing simple architectures. So would you prefer a simple architecture or a complex one? The answer should be obvious.
- calpaterson 4y ago> GraphQL libraries weren’t great when we adopted GraphQL (the base Python library was a port of the Javascript one so not Pythonic, Graphene required a lot of boilerplate, Apollo-Android produced very poorly optimized code) What do people use instead of Graphene? Strawberry?
- fernandogrd 4y agoThere is also ariadne
- AceJohnny2 4y ago> one major African market requires we operate our “primary datacenter” in the country What country could that be? That sounds challenging.
- taeric 4y agoMy favorite trap in all of this, is that this thinking will fail most tech interviews. It is incredibly frustrating.
- mkl95 4y agoI guess the only thing you can do is avoid those places. Last time I checked Wave were on a hiring spree.
- wanda 4y agoI think that probably says more about the tech companies than anything else.
- bob1029 4y agoTrap or integrated win-win? We use one of these "aggressively simple" architectures too. At this point, I would quit my job instantaneously if I had to even look at k8s or whatever the cool kids are using these days.
- WrtCdEvrydy 4y ago> look at k8s or whatever the cool kids are using these days. I'm fine with complex architecture and would actually welcome someone choosing something complex but the issue is that we have perverse incentives at work to introduce stuff just to pad our resume. Kubernetes was designed for companies deploying thousands of small APIs/applications where management is a burden. I've seen companies that deploy 3 APIs running Kubernetes and having issues...
- adra 4y agoMan, kubernetes is so much easier than the smattering of crap that you have to jungle together before it. Puppet and co? No thanks. Terraform? It's fine, but only a part of a CI/CD picture. If you think the alternatives are better, I really have to wonder how much of the trenches crap that people in your org deal with regularly that you're insulated from. That, or you're a release-quarterly kinda company?
- surfer7837 4y agoJust boils down to not optimising until you need to. Start with a 3 tier web app (unless your requirements lead you to another solution), then start with read replicas, load balancing, sharding, redis/RabbitMQ etc
- zrail 4y agoRealistically almost every web app can start as a one-tier web app that uses SQLite as a data store and serves mostly HTML.
- deleted 4y ago[deleted]
- a9h74j 4y agoI have a dumb question ... In almost all performance areas -- gaming, PCs, autos, etc -- there are usually whole publications dedicated to performing benchmarks and publishing those results. Are there any publications or sites which implement a few basic applications against various new-this-season "full stacks" or whatnot, and document performance numbers and limit-thresholds on different hardware? Likewise, there must be stress-test frameworks out there. Are there stress-test and scalability-test third-party services?
- zie 4y agoFossil SCM is a great example of a sqlite application that has stood the test of time. I don't know what sqlite.org's traffic is like, but it's not tiny and it runs on a tiny VPS without issue(and has for years now).
- SpikeMeister 4y agoTechEmpower has benchmarks for different web stacks: https://www.techempower.com/benchmarks/ https://www.techempower.com/benchmarks/
- gmfawcett 4y ago
- ryanbrunner 4y agoI think especially for small teams starting out, complex architecture can be a huge trap. Our architecture is extremely simple and boring - it would probably be more-or-less recognizable to someone from 2010 - a single Rails MVC app, 95+% server-rendered HTML, really only a smattering of Javascript (some past devs did some stuff with Redshift for certain data that was a bad call - we're in the process of ripping that out and going back to good old Postgres) Our users seem to like it though, and talk about how easy it is to get set up. Looking at the site, the interactions aren't all that different from what we would build if we were using a SPA. But we're just 2 developers at the moment, and we can move faster than much larger teams just because there's less stuff to contend with.
- woah 4y agoThat doesn't sound like it's really any simpler than a json API server (written in node, python, go, or anything else), and a SPA. Maybe the lesson is "build with what you know if you want to go fast".
- ryanbrunner 4y agoIn my experience SPAs bring a lot of headaches that you just don't really need to think about with traditional HTML. Browser navigation, form handling, a lot of accessibility stuff comes out of the box for free, and there's one source of truth about what makes a particular object valid or how business logic works (which is solvable in the SPA world but brings a lot of complexity when you need to share logic between the client and the server, especially when they're in different languages). Frankly out of all the things that make our architecture simple and efficient, I would say server rendered HTML is by far the biggest one.
- woah 4y agoProbably depends on the requirements. If the product should basically feel like a static web page, and you are OK making design and product decisions that work easily in that paradigm, then a server side framework built to make static web pages is going to be simpler. If you have product or design requirements that it should feel more dynamic like a native app, then trying to patch that on top of a static webpage might get messy.
- ilovecaching 4y agoThe vast, vast, vast majority of organizations don't need micro services, don't need half of the products they bought and now have to integrate into their stack, and are simply looking to shave their yak to meet the bullet list of "best practices" for year 202X. Service oriented architectures and micro services solve a particular problem for companies that are operating on a massive scale and can invest (read waste money) on teams devoted to tooling. What most companies should do is build a monolith that makes money, but hire good software engineers that can write packages/modules whatever with high levels of cohesion and loose coupling, so that one day when you become the next Google, it will be less of a pain to break it into services. But in the end it really doesn't matter if it's painful anyway, because you'll have the money to hire an army of people to do it while the original engineers take their stock and head off to early retirement.
- danielvaughn 4y agoI'd never worked with micro-services before this latest freelance project. I start working with this platform that is basically "note taking but with a bit of AI/ML". So okay, a bit of complexity with the ML stuff, but otherwise a standard CRUD app. The application itself is a total of 3 pages, encompassing maybe 20 endpoints at the most, with about 100 daily active users. For the backend, some genius decided to build a massive kubernetes stack with 74 unique services, which has been costing said company over $1K/month just in infra costs. It took me literally weeks to get comfortable working on the backend, and so much stuff has broken that I have no idea how to fix. Not only that, but the company has never had more than 1 engineer working on it at a time (they're very small even though they've been around a bit). If there were such a thing as developer malpractice, I'd sue whoever built it.
- DerArzt 4y ago> 3 pages .... 74 unique services Just, wat. Sounds like the architect was doing some resume driven development cause damn.
- Calamitous 4y ago
- bob1029 4y agoI think the biggest problem for most developers is not understanding what one computer can actually do and how reliable they are in practice. Additionally, understanding of how tolerant 99% of businesses are to real-world problems that could hypothetically arise can help one not frustrate over insane edge case circumstances. I suspect a non-zero number of us have spent time thinking about how we could provide deterministic guarantees of uptime that even unstoppable cosmic radiation or regional nuclear war couldnt interrupt. I genuinely hope that the recent reliability issues with cloud & SAAS providers has really driven home the point that a little bit of downtime is almost never a fatal issue for a business. "Failover requires manual intervention" is a feature, not a caveat.
- trasz 4y agoAlso, those complicated architectures are often quite unreliable anyway - just in ways that don't show in metrics. Slack comes to mind: not only its functionality is poor compared to eg IRC, but it fails in hilarious ways, eg showing duplicated messages, or not showing them at all. Another example is YouTube - the iOS app gets confused when displaying an ad, which results in starting the playback at a wrong time offset. I guess it's because companies like those don't care about actual reliability - what they do care about is availability.
- joshlemer 4y agoHow could you say that Slack has poor functionality compared to IRC?
- exfascist 4y agoWhen you type something into IRC that message shows up in the log and every online users client pretty reliably. Furthermore the high degree of diversity among clients provides a pretty extreme amount of client side functionality that Slack completely lacks (scripting is a huge one.)
- spicybright 4y ago
- scrubs 4y agoNah, I don't much like the tone of this article. Not at all. The engineering message should be: keep your architecture as simple as possible. And here are some ways (to follow) on how to find that minimal and complete size 2 outfit foundation in your size 10 hoarder-track-suite-eye-sore. Do we really need to be preached at with a warmed over redo of `X' cut it for me as a kid so I really don't know why all the kids think their new fangled Y is better? No we don't. If you have stateless share nothing events your architecture should be simple. Should or could you have stateless share nothing even if that's not what you have today? That's where we need to be weighing in. Summary: less old guy whining/showing-off and more education. Thanks. From the Breakfast club kids.
- rendall 4y agoI'm not sure why this particular author is so popular on HN, but he hits the front page regularly.
- kragen 4y agoBecause he says things that are true and less well known than they should be, and then gives a clearly written argument that shows you that they are true using logic and empirical evidence. So far that just describes any good science paper or math textbook; the difference is that he's writing about questions of great interest to HN, like in this case "how to build a web service", "how to do software version tracking" (https://danluu.com/monorepo/ https://danluu.com/monorepo/), "how to do statistics" (https://danluu.com/linear-hammer/ https://danluu.com/linear-hammer/), "why hardware development is hard" (https://danluu.com/why-hardware-development-is-hard/ https://danluu.com/why-hardware-development-is-hard/), "why everything is broken" (https://danluu.com/nothing-works/ https://danluu.com/nothing-works/), and "how to hire talented people" (https://danluu.com/talent/ https://danluu.com/talent/). These are topics where there is an enormous amount of hot air out there on the web, but very little that is epistemologically justifiable.
- rendall 4y agoI don't disagree with you, but other people write on these topics more compellingly, and do not include off-putting Wolfram/Doctorow-style self regard. I chalk it up to his being astoundingly prolific. https://news.ycombinator.com/from?site=danluu.com https://news.ycombinator.com/from?site=danluu.com
- endisneigh 4y agoHow far can you get with a single Postgres instance on a single machine? I know things like cockroach and citus existence but generally Postgres isn’t sharded as far as I know.
- zozbot234 4y agoPostgres supports sharding out of the box. The documentation tells you how to do it, using foreign data wrapper and table partitioning.
- zie 4y agoPretty far!
- endisneigh 4y agoHow far was exactly? Like tps for reads and writes with what specs? I’ve been looking for real world performance.
- zie 4y agoThat's complicated based on workload, etc. A single PG node will obviously never scale to Google or Facebook levels. Attend a PG conference and you will run into plenty of people running PG with similar use cases(and maybe similar loads) to you. I can say we run a few hundred concurrent users backed by PG on a small to medium sized VPS without issues. Our DB is in the 3 digit GB range on disk, but not yet TB range.
- bpicolo 4y ago50k-100k reads per second was pretty doable on mysql even back in 2014-2015 era. You can get a 60TB NVMe instance with 96 cores these days - https://aws.amazon.com/ec2/instance-types/i3en/ https://aws.amazon.com/ec2/instance-types/i3en/. Relational databases just scream on the dang things. > 2 million random IOPS at 4 KB block sizes and up to 16 GB/s of sequential disk throughput
- dan-robertson 4y ago
- pavlov 4y agoThere are some web apps still in production that I wrote almost a decade ago in Node+Express in the simplest, dumbest style imaginable. The only dependencies are Express and some third-party API connectors. The database is an append-only file of JSON objects separated by newlines. When the app restarts, it reads the file and rebuilds its memory image. All data is in RAM. I figured these toys would be replaced pretty quickly, but turns out they do the job for these small businesses and need very little maintenance. Moving the app to a new server instance is dead simple because there's basically just the script and the data file to copy over, so you can do OS updates and RAM increases that way. Nobody cares about a few minutes of downtime once a year when that happens. There are good reasons why we have containers and orchestration and stuff, but it's interesting to see how well this dumb single-process style works for apps that are genuinely simple.
- ammanley 4y agoReminds me a lot of this (first paragraph): https://litestream.io/blog/why-i-built-litestream/ https://litestream.io/blog/why-i-built-litestream/ Well done on building an easy-to-maintain single node app with few dependencies. You would be the SWE I would send prayers of thanks too after onboarding (and for not making me crawl through a massive Helm chart/CloudFormation template hell).
- mftb 4y agoI do almost this exact thing for all my personal stuff. I have 5 or 6 going in a vm for simple things like my bookmarks, etc... works great. I could definitely see it solving many small business use-cases.
- mbrodersen 4y agoI suspect that 95% of business applications could be implemented just fine with that architecture. However I would use SQLite instead of a plain file. Just for added commit safety.
- kragen 4y agoFor simple write patterns like this, I've had better robustness experiences with dumb filesystem access than with SQLite.
- dang 4y agoWhat's the year on this? anybody know? Normally I check the Internet Archive, but https://web.archive.org/web/*/https://danluu.com/simple-architectures/ https://web.archive.org/web/*/https://danluu.com/simple-arch....
- Jtsummers 4y agoThe "previous" article at the bottom is the most recent article in his archive, which was apparently published in March 2022. So I'm guessing this year, and either this month or last month. But the archive doesn't seem to have been updated yet with this article.
- deleted 4y ago[deleted]
- Beltalowda 4y agoBased on Dan's Twitter, March 2022: https://twitter.com/danluu/status/1501644166983421953 https://twitter.com/danluu/status/1501644166983421953 That links to the original on wave.com, dated March 9th this year.
- gherkinnn 4y agoAt the risk of making an ad-hominem attack, I found this website unreadable. Minimalism is fine. But there comes a point when there's so little, it is nothing. danluu.com is a bucket of sand facing an overbuilt cathedral.
- dan-robertson 4y agoYou can read the same content here: https://www.wave.com/en/blog/simple-architecture/ https://www.wave.com/en/blog/simple-architecture/
- Beltalowda 4y agoI set a user style in Stylus for danluu.com: body { font: 16px/1.6em sans-serif; max-width: 50em; margin: auto; } Can even add it manually in the inspector if you want.
- mpyne 4y agoI do something similar, except it's the CSS from whatever of the 'Better Fucking Website' hits come up for me on search each time. I do wish I didn't have to do that though.
- Beltalowda 4y agoI find it's a lot easier to add a simple CSS to an understyled website, than remove huge fixed banners, weird low-contrast thin fonts, etc. from overstyled websites.
- throwaquestion5 4y agoThanks for sharing. Personally I also add background-color: #edd1b0; for any site I plan on read more than five minutes. For me is more pleasant to read compared with than a white background.
- chubot 4y agoReader mode in your browser goes a long way, I think they all have it now
- reggieband 4y agoI understand his point but I actually think micro-services can be simpler than monoliths. Even for his architecture, it sounds like they have an API service, a queue and some worker processes. And they already have kubernetes which means they must be wrapping all of that in docker. It seems like a no-brainer to me to at least separate out the code for the API service from the workers so that they can scale independently. And depending on the kind of work the workers are doing you might separate those out into a few separate code bases. Or not, I've had success on multiple projects where all jobs are handled by a set of workers that have a massive `switch` statement on a `jobType` field. I think there is some middle ground between micro-services and monoliths where the vast majority of us live. And in our minds we're creating these straw-man arguments against architectures that rarely exist. Like a literal single app running on a single machine vs. a hundred independent micro-services stitched together with ad-hoc protocols. Micro-services vs. monoliths is actually a gradient where we rarely exist at either ludicrous extreme.
- deterministic 4y agoIt is pretty much impossible for a micro-service architecture to be simpler than a well designed monolith. To create a micro-service architecture from a well designed monolith you need to take the N libraries the monolith is built from and add protocols/serialisation/deployment etc. to each library. Each of which adds new distributed failure scenarios you now have to test/handle.
- lifefeed 4y agoI was interviewing for software jobs recently, and while I was studying up on the "system design" portion I kept circling around the same insight that Dan Luu writes about so well here. I would sit down at an interview and try to create these "proper" system designs with boxes and arrows and failovers and caches and well tuned databases. But in the back of my mind I kept thinking, "didn't Facebook scale to a billion users with PHP, MySQL, and Memcache?" It reminds me of "Command-line Tools can be 235x Faster than your Hadoop Cluster" at https://adamdrake.com/command-line-tools-can-be-235x-faster-than-your-hadoop-cluster.html https://adamdrake.com/command-line-tools-can-be-235x-faster-... , and the occasional post by https://rachelbythebay.com/w/ https://rachelbythebay.com/w/ where she builds a box that's just fast and with very basic tooling (and a lot of know-how).
- rr808 4y agoYeah I just did an interview where my design was a database, a few lambdas and a webserver and after I was thinking they must think I dont know much, I should have beefed it up a bit.
- barbazoo 4y agoIt's important to justify the design you come up with. Explain why the design is simple, pros and cons and when you'd opt for a more complicated one to solve which particular issue.
- mapme 4y agoI think that’s a large oversimplification of Facebook. While it’s true a lot of FB storage is MySQL backed they also created many complex systems such as: - Cassandra (based on dynamo/big table) - wrote a custom KV store named RocksDb that is open source/now a company - wrote a custom photos storage system that replaced an NFS based design - wrote another custom binary object store - wrote a custom geo distributed graph db (Tao) - wrote an in house distributed FS replacement for HDFS https://www.cs.cornell.edu/projects/ladis2009/papers/lakshman-ladis2009.pdf https://www.cs.cornell.edu/projects/ladis2009/papers/lakshma... https://www.usenix.org/legacy/event/osdi10/tech/full_papers/Beaver.pdf https://www.usenix.org/legacy/event/osdi10/tech/full_papers/... https://www.usenix.org/system/files/conference/osdi14/osdi14-paper-muralidhar.pdf https://www.usenix.org/system/files/conference/osdi14/osdi14... https://www.usenix.org/system/files/conference/atc13/atc13-bronson.pdf https://www.usenix.org/system/files/conference/atc13/atc13-b... https://www.cs.princeton.edu/~wlloyd/papers/tectonic-fast21.pdf https://www.cs.princeton.edu/~wlloyd/papers/tectonic-fast21.... https://m.facebook.com/nt/screen/?params=%7B%22note_id%22%3A10158791582997200%7D&path=%2Fnotes%2Fnote%2F&refsrc=deprecated&_rdr https://m.facebook.com/nt/screen/?params=%7B%22note_id%22%3A...
- aidos 4y agoIn terms of the choices they're unsure about; I'd say it's best to stay away from Celery / RabbitMQ if you don't really need it. For us just using RQ (Redis backed queue) has been a lot less hassle. Obviously it's all going to depend on your scale, but it's a lot simpler. RE the sqlalchemy concern; you do need to decide on where your transactions are going to be managed from and have a strict rule about not allow functions to commit / rollback themselves. Personally I think that sqla is a great tool, it saves a lot of boilerplate code (and data modelling and migrations are a breeze). But overall the sentiments in this article resonate with my experience.
- sydthrowaway 4y agoWhat is Wave?
- pphysch 4y agoAfrican fintech backed by Stripe
- flakiness 4y agoTangent: How do you read danluu.com? I'm using readermode.io and it's fine, but would love to hear what other people are using.
- wackget 4y agoA web browser.
- wackget 4y agoI don't know how the author can claim that they run a "simple" architecture. From their job pages: Our stack : backend: Python 3 (+ mypy) API layer: GraphQL android frontend: Kotlin/Jetpack iOS frontend: Swift/SwiftUI web frontend: TypeScript/React database: Postgres infrastructure: GCP / Terraform orchestration: Kubernetes That is not simple by any stretch of the imagination.
- rendall 4y agoHow would you simplify this?
- nunez 4y agofor starters i wouldnt use kubernetes. love the system, but boy is it complicated. i'd use a few cloud function or stick them in VMs behind a load balancer and call it good.
- polio 4y ago> As for Kubernetes, we use Kubernetes because knew that, if the business was successful (which it has been) and we kept expanding, we’d eventually expand to countries that require us operate our services in country. The exact regulations vary by country, but we’re already expanding into one major African market that requires we operate our “primary datacenter” in the country and there are others with regulations that, e.g., require us to be able to fail over to a datacenter in the country.
- deleted 4y ago[deleted]
- jameshart 4y agoThis doesn't sound very simple at all. It's a single codebase that handles all your mobile API interactions, authentication, account management, presumably usage tracking and notifications, and all your offline processing, all interacting with a single database and queue infrastructure? And that same codebase marshalls all that through a GraphQL API and implements a custom data protocol? And you're calling that simple? I've worked on monolithic codebases, and the one thing none of them have ever been is simple. They have complex interdependencies (oh hey, like database transaction scopes); they have that 'one weird way of doing things' that affects every part of the system (like, 'everything has to be available over GraphQL')...
- mbrodersen 4y agoI have worked on massive well designed monoliths and they were so much easier to maintain than equivalent micro-service implementations would have been. Monoliths and Micro-services will be easy/hard/impossible to maintain depending on how well they are designed. Not depending on whether it is a monolith or micro-service architecture.
- lliamander 4y agoSo, I definitely agree with this. Most of us don't have to do any thing at FAANG scale. But what counts as simple? It's quite easy these days to deploy an app using AWS Lambda, DynamoDB, SNS, etc., all with a single Cloud Formation template. Is that simple? In one sense I've abstracted away a lot of the operational work that comes with self-hosted, but now I've intertwined (Rich Hickey might say complected) myself into Amazon's ecosystem. Also, is a document store like DynamoDB, MongoDB, etc., simpler than a relational database like Postgres? On the one hand, a document database's interface is very simple compared to the complexity like SQL. On the other, that simplicity is generally considered a necessary sacrifice to scale. If you don't need to scale, why make the sacrifice? Also, there can be simple things that are better at scaling. Elixir is a very nice scripting language like Ruby or Python, but it also has much better performance scaling (comparable with NodeJS or Go).