21 ms·
This sentiment pops up regularly on HN, and I've seen at least one article per month for the past few months, but the trouble is, none of them seem to help you
by irskep 4y ago
This sentiment pops up regularly on HN, and I've seen at least one article per month for the past few months, but the trouble is, none of them seem to help you actually deploy it. They assume you're comfortable spinning up public web servers.
If you want to use a PaaS to deploy an app, because you don't want to spend your time learning to be a sysadmin, then all the tutorials are going to put you on the Postgres path, because that's what's supported. (Of course, you'll then end up paying $15+/mo for Postgres, which is hilarious for most hobby projects storing 50MB of data.) But in reality, you could just scale vertically on one machine and be completely fine. No need for "distributed" anything, in theory.
I took a shot at productionizing SQLite here as an experiment: https://cheapo.onrender.com/ https://cheapo.onrender.com/
But I'm not sure I did it right, because I don't have much experience working below the level of a PaaS. I'm an application developer and I do not want to become a release engineer. I resent even having to learn Docker. :-)
Anyway, if somebody wants to nitpick my Flask+SQLite deployment, I'd really appreciate it, because it seems really silly that people have to keep writing this stuff from scratch when 90% of hobby sites have the exact same needs. And the Fly.io/Render configs would apply just as well to Node, Ruby, etc. https://github.com/irskep/cheapo_website https://github.com/irskep/cheapo_website
Edit: Somebody got mad at the Docker bit. I tossed it in for effect, but I promise you I don't hate learning new skills. I wish people would recognize that weekend coding projects should be fun, and sometimes that means avoiding certain kinds of things that a person experiences as difficult or frustrating. Arguing on the internet sucks, who knew?
- canadiantim 4y agoNote with Neon now you don't need to spend $15+/mo for Postgres because they separate compute from storage. So compute can scale down to 0 and storage is cheap.
- hamandcheese 4y agoNeon only recently entered public preview and I am unable to find any pricing information.
- nikita 4y agoLaunching on mar 15th
- canadiantim 4y agoCongrats on the upcoming launch! I'm definitely very strongly considering using Neon in my upcoming project. Mind if I ask a couple questions? Would you be able to comment on if Neon is a good fit for having one postgres database per user and how well that would scale? E.g. what if millions of users? Also with the managed service, is there help with applying migrations or helping manage migrations for such a multitude of postgres databases? Lastly, is there any way of querying across neon databases, e.g. aggregating data from many user's databases? I saw you partnered with Hasura a bit. Hasura would be a great fit here for aggregating and "federating" each user's postgres database, but with their most recent price change I'm scared of integrating too much with them. Wondering how you think one can best query e.g. a million user's individual postgres databases? Thank you and feel free to ignore I know it's kinda asking alot
- nikita 4y agoOne database per user is something many of our customers are already using today. I think if there are millions of users it’s a bit of an overkill. Because likely you will have some very light users that you can still collocate on one database but give heavy users a dedicated one. With Neon you can do either. Our minimum configuration is 1/2 core which may still be too much for one light user.
- canadiantim 4y agoThank you! That makes a lot of sense. Yes its probably overkill to do one db per user. Better to split off when they become heavier users. Thanks again for the awesome tech eh and good luck on the formal launch!!
- somsak2 4y agois $15/month really that much of an expense? i share my PostgreSQL instance across projects, really does not seem like that big of a deal to me considering it's such a big hobby of mine.
- danielmarkbruce 4y agoIt's a c library. Other languages will have a library/package/whatever to use it. You point it at a file.
- paranoidrobot 4y ago"Just point it a file" skips all the bits you need for a production system. How do you back it up, replicate it, handle two different processes/containers/servers wanting to access the same data. Using a PAAS solution for a database, you get all that functionality.
- samtho 4y agoI think the point to be learned here is that SQLite fundamentally does not fit in a PaaS model. They are even transparent with this limited use case[0]. I work with embedded systems so I use it a lot, and all the web work I do nowadays is one-off project site and small utilities that are usually a single process so I end up use SQLite 90% of the time I’m reaching for a solution. 0: https://www.sqlite.org/whentouse.html https://www.sqlite.org/whentouse.html
- irskep 4y agoI think it's more that PaaS vendors aren't interested in first-class SQLite support when they can sell overpriced managed Postgres instead. Sure, it doesn't scale the same way, so it's hard to move upmarket and sell to Enterprise, but it's a shame that there's no one-click solution like there is for a managed database.
- azurelake 4y agoLet's say the following product existed: 1. You can only run one instance of your app. 2. There is a small window of downtime each deploy. 3. Your app has access to 10 GB of storage. The storage is persisted across deploys and can be used for sqlite. 4. Your sqlite data is automatically backed up and can be restored / downloaded as needed. How much per month would you pay for that product?
- chrismarlow9 4y agohttps://news.ycombinator.com/item?id=33975635 https://news.ycombinator.com/item?id=33975635 is a previous discussion with some pointers that is linked from the primary sqlite website https://www.sqlite.org/whentouse.html https://www.sqlite.org/whentouse.html See the "website" section for some benchmark estimates.
- chasil 4y agoThe problem is when you start to approach oltp. This is not a space for sqlite. I have thought about jacking inotify into sqlite_busy_handler() to get the exclusive writers doing better than random waits, but this full api isn't exposed to PHP (where I need it), and doing it at C would suggest alternate approaches, maybe even with xargs at the shell. Oracle has a DBWR process that manages itself, but a write-heavy app on sqlite must explicitly declare one, and there are many further traps down this path that will trip the unwary.
- srcreigh 4y agoI don’t get this. SQLite can perform 500k writes/s (or 5k write txns/s). What app are you building which requires more than this?
- chasil 4y agoTo optimize the writes, you must look at inotify. The sqlite commit is a specific pattern, it is either write or close/write. Using inotify events can see these faster than random waits.
- srcreigh 4y agoRespect. I’m curious what use case for >500k writes/second or 5k write txns/second you’re implementing? I know nothing about inotify and random waits. What else can you tell me?
- chasil 4y agoIn SQLite's C API, there is a busy handler that you can set that accepts a pointer to a function. This is where inotify would be very practical: https://sqlite.org/c3ref/busy_handler.html https://sqlite.org/c3ref/busy_handler.html The normal operation of the busy handler is to accept a maximum timeout (also implement at the SQL level with a PRAGMA). Setting this at the C API also sets a dedicated handler. https://sqlite.org/c3ref/busy_timeout.html https://sqlite.org/c3ref/busy_timeout.html The inotify interface (which is specific to Linux) allows the kernel to alert a process when writes or close/writes occur (among other filesystem activities). The arrival of such events is a more efficient way to check if the lock has been released, rather than a wait/retry of limited duration. Let's look at this from the shell: # session 1: $ sqlite3 test.db SQLite version 3.34.1 2021-01-20 14:10:07 Enter ".help" for usage hints. sqlite> create table foo(bar); sqlite> .quit # session 2: $ inotifywait -m test.db Setting up watches. Watches established. # session 1: $ sqlite3 test.db SQLite version 3.34.1 2021-01-20 14:10:07 Enter ".help" for usage hints. sqlite> insert into foo values('hello, world!'); sqlite> begin transaction; sqlite> insert into foo values('so long, world!'); sqlite> delete from foo; sqlite> commit; sqlite> .quit # session 2 output: Setting up watches. Watches established. test.db OPEN test.db ACCESS test.db CLOSE_NOWRITE,CLOSE test.db OPEN test.db ACCESS test.db ACCESS test.db ACCESS test.db ACCESS test.db MODIFY test.db ACCESS test.db MODIFY test.db CLOSE_WRITE,CLOSE "Path units" under systemd also use this interface.
- ericHosick 4y ago> Of course, you'll then end up paying $15+/mo for Postgres, which is hilarious for most hobby projects storing 50MB of data. Supabase (https://supabase.com/pricing https://supabase.com/pricing) has an amazing free tier for PostgreSQL which gives you up to a 500MB database. Note: I'm not affiliated in any way with supabase.com.
- irskep 4y agoHey that's really cool, thanks! I'll consider adding a link to it in the repo. I'm a little skeptical that any given PostgreSQL free tier will stick around indefinitely, after what happened with Heroku. And once you hit 500MB, you jump immediately to $25/mo, so if you're running a hobby project, your choice is either to delete data or start paying $300/year. On the other hand, I'd expect a well-optimized read-heavy SQLite app to scale to 10GB+ without breaking a sweat (speculating wildly) and costing more like $3/mo in storage. I speak from experience here—until recently, I ran a site that would have been 10x cheaper if it had used pure SQLite instead of managed Postgres.
- cutler 4y agoPasS my ass. What's so difficult about setting up a VPS and installing PostgreSQL, MySQL or whatever floats your boat? At Hetzner.com (no I don't work for them) you can get a dual-CPU VPS with 4Gb RAM, 40Gb SSD and 20TB traffic. That'll get you off to the races with Spring Boot and PostgreSQL if you limit the JVM to half the available RAM. For something like Rails, Laravel or Express even easier.
- joshmn 4y agoBy doing so, I am a failure, and whatever I'm doing is not worthwhile because installing PostgreSQL on my $20 VPS means I cannot possibly achieve /Google/Facebook/Amazon/ scale.
- aww_dang 4y agoFor that price you can get a $10 dedicated server with similar specs. Installing and configuring Postgres isn't a big deal. There are several helpful guides available. For small projects the config isn't important at all. For everything else it is just editing a few lines in a text file. I'm not sure where the impression that this is some arcane art comes from. For a typical Debian system it is just an apt-get. Yes, the default config has tiny limits for work_mem. Just edit the .conf Part of this might be that AWS or whichever other proprietary environment has captured developer knowledge at this point. Instead of sane INSTALL files, projects tell users to use a prepacked Docker image.
- bogwog 4y ago> I'm an application developer and I do not want to become a release engineer. I resent even having to learn Docker. :-) Sorry, but that's a terrible attitude to have. You don't need to be a full-blown sysadmin to know how to do basic deployments, and learning these things will make you a better developer.
- guggle 4y agoI don't know why this is downvoted, it's probably the best advice on this page. Learning a few things about deployment definitely helps to make better software.
- ilyt 4y agoThat often quickly leads to "chmod -R 777 makes the app work and I don't give a shit about doing it properly" if your passion is dev, not ops
- irskep 4y agoWell, he did cherry-pick one joking comment out of a well-intentioned post in order to say I have a bad attitude, so that's not exactly welcoming. And very patronizing, considering I have actually done that kind of work with Salt Stack a few years ago, and just don't want to bother with it at the moment because I have other priorities. I learn new things every day, and one day, Docker was that thing. I am now better at release engineering, cool! But I also lost a day of working on shipping value to users and actually having fun, which is less cool. That's why PaaS has been helpful to certain kinds of people; it makes the curve of progressive disclosure necessary to deploy stuff a little flatter. My hope is that we can make more kinds of things really easy to do the right way, and not yell at people who just want to have some fun.
- guggle 4y agoSure, that comment came a bit rough. But I'm not even sure it was triggered by the Docker comment, rather than the developer/release engineer opposition. At least that's how I see it. And maybe I just don't see the added value of PaaS because I've been spinning up public web servers for too long now ;-)
- canadianfella 4y agoWhy do people use hosted databases instead of just installing them? I don’t understand it.
- erik_seaberg 4y agoIf you install your own copy, you are on call for it, and the colo is unlikely to offer much help. You also have to set up monitoring or you won’t even know when it fails. Then there’s replication. Backups. All this stuff is work that PaaS vendors are ready to automate away, if my time is expensive for the org. For fun, sure, dink around and learn as long as there are no customers to affect.
- canadianfella 4y agoCan’t you just run a script that sets all that up for you? Just like any other programming task?
- erik_seaberg 4y agoI suppose Terraform could do it (I’m pleasantly surprised to see it has a PagerDuty plugin), but it’s a lot more to write than a PaaS API, and you probably can’t borrow a specialist SRE/DBA for a small fraction of his salary.
- riku_iki 4y agofrom another hand, vendor can screw things up and you don't have control over it.
- pdimitar 4y agoYou are not wrong but for each personal project this upfront cost is 2 hours maximum, with accumulated 5-6 more over the course of the next 3-6 months. Not a huge sacrifice. Though I do get the argument of "I want to pay $5 and it to just work" and I've done so part of the times. Just pointing out that the upfront investment in doing it on your own is not so big.
- 4y ago
- benhoyt 4y agoJust this morning I was wondering about where to host the next iteration of my side project (GiftyWeddings.com). It currently uses Go + SQLite, and I deploy it to a small $9/month instance on AWS, but the setup involves a bunch more Ansible and messing around than I want, and I'm not even sure the Ansible scripts I wrote a few years ago would work anymore (or work a second time). A simpler PaaS-like system that works with SQLite at a few bucks a month would be great. I'll check out your repo and fly.io in more depth -- thanks!
- yawaramin 4y agoPocketBase is worth a look. It can run standalone as an API server that wraps access to the SQLite database, or it can be used as a Go framework.
- srcreigh 4y agoI don’t get this. Go can be compiled to a single binary containing SQLite. Scp the executable and run it. This will work on any Linux vm without any setup…
- benhoyt 4y agoThat's what I do now. But there's a bunch more setup: - Install and configure Caddy to terminate the SSL. Caddy is great, but still stuff to think about and 20 lines of config to figure out. - Configure systemd to run Caddy and my Go server. Not rocket science, but required me figuring out systemd for the first time and the appropriate 25-line config file for each server. - Scripts to upgrade Caddy when a new version comes out (it wasn't in the apt repos when I did this). - Ansible setup scripts to clone the repo, create users and groups for Caddy and my Go server, copy config files, add cron jobs for backups (150 lines of Ansible YAML). It looks like you don't need most of this, or get it without additional configuration with Fly.io and Render. It's kind of like the difference between Dropbox and "you can already build such a system yourself quite trivially by getting an FTP account, mounting it locally with curlftpfs, and then using SVN or CVS on the mounted filesystem. From Windows or Mac, this FTP account could be accessed through built-in software." (https://news.ycombinator.com/item?id=28153080 https://news.ycombinator.com/item?id=28153080)
- noisenotsignal 4y agoThis is cool to see! I’ve been working on a website for online ordering, and a key requirement is free hosting [0]. After some searching I figured fly.io + SQLite would be enough for my use case but I can’t be 100% sure until I actually deploy, which I haven’t yet. It’s nice to know someone else has done it this way successfully! [0] - It’s for a small business not in the US with no serious requirements on availability etc so free, or close to it, seems achievable.
- swlkr 4y agoI've used dokku to great effect. SSHing into a new linux VPS can be intimidating but there a few good digital ocean tutorials that'll take you from new VPS to dokku and once you're there it's very much a PaaS
- satoru42 4y agoYou didn't add all points to Strength so you could only be a "application developer", did you?
- ghusto 4y ago> They assume you're comfortable spinning up public web servers I'd argue you should be. I'm currently learning a low level language. It has nothing to do with my job, will not directly be a benefit to my work, and won't look good on my C.V. It will (and has) _indirectly_ improved my work, because I have a better understanding of why certain things higher up are the way they are, which allows me to make better decisions. You can ignore everything that's not "your area", whatever that might be, but I'm my opinion it means you'll be stuck at a certain invisible level because of it.
- ilyt 4y ago>Of course, you'll then end up paying $15+/mo for Postgres, which is hilarious for most hobby projects storing 50MB of data. You can run small project on $5 VPS with Postgres just fine tho... Managed services in cloud are usually massively overpriced
- lenkite 4y agoAlso "as long as your web application can run on the same machine as the database, which it can in 99% of the time" Where did 99% of the time come from ?
- pdimitar 4y agoNot the poster you replied to but from my anecdotal experience -- from most of my work ever. I can only remember 3 companies out of all 40+ I consulted and contracted for that actually needed a separate machine for app and a DB, let alone such that actually truly need several of each. It's a very non-romantic truth but most projects out there can easily fit in a VPS with 4 CPU cores, 8GB ram and 100-200GB SSD space. App + DB + self-hosted telemetry included.