webology,
@webology@mastodon.social avatar

⬇️ This is a nice write-up about using SQLite in production, with pitfalls and open questions.

😓 I cringe whenever I see some Django/Python luminary recommending people use SQLite in production. I don’t care how good you are, you won’t get it right even if you think you did. Then, someone will read your advice and contact @djangonews to ask why their production database disappears every time they deploy their website or unexpectedly. https://fosstodon.org/@anze3db/111765707787892711

carlton,
@carlton@fosstodon.org avatar

@webology @djangonews On the “Use Boring Technology” way of thinking, choosing SQLite is choosing to spend one of your innovation tokens there.

There aren’t many projects where that’s a good spend, at least for most folks.

webology,
@webology@mastodon.social avatar

@carlton @djangonews how many innovation tokens do we get?

Curious if you have written about this and I missed it, or if you read something that inspired it? (I'd read it if you wrote about it too)

carlton,
@carlton@fosstodon.org avatar

@webology @djangonews “not many” is the usual answer. Assuming you’re building an app you have to think about that is.

Ah, yes. (Glances at backlog 😅). The boring tech idea is the famous talk. But choosing SQLite specifically (or why still not really) is something I’ve been thinking about.

webology,
@webology@mastodon.social avatar

@carlton I have several articles 80% done in my backlog.

I think February might be my month to push some out the door.

Most fall into the low-tech or "boring tech" camp, like the dozens of copy-to-clipboard apps I write, use, and embed in everything.

carlton,
@carlton@fosstodon.org avatar

@webology This is the way.

fallenhitokiri,
@fallenhitokiri@social.screamingatmyscreen.com avatar

@webology @carlton @djangonews our rule of thumb is 3.

Brand new infrastructure or frameworks are worth three tokens.

A new service with a small blast radius 2.

A small, isolated library 1.

Rewrites of any kind: 5. :)

webology,
@webology@mastodon.social avatar

@fallenhitokiri @carlton Your story points sound about right.

🤔 I'm Going to go with 11 on the rewriting and porting story though.

_chrismay,
@_chrismay@fosstodon.org avatar

@carlton @webology This is a fascinating reasoning to me. From my perspective, SQLite is a boring technology.

Clearly I don't have your experiences to have a different perspective.

Is it that it's not a boring technology from a Django perspective? Or am I askew with my database perspectives?

carlton,
@carlton@fosstodon.org avatar

@_chrismay @webology You’d need to be committed to the claim that “SQLite is the/a standard choice for web application database backends” for it to be “Boring Tech” in the sense in question.

_chrismay,
@_chrismay@fosstodon.org avatar

@carlton @webology Ah! That makes sense. Thanks!

webology,
@webology@mastodon.social avatar

@carlton @_chrismay I think it's great for local dev and showing someone how to get started.

Then you hit some immediate footguns in production that aren't obvious until you have lost data.

_chrismay,
@_chrismay@fosstodon.org avatar

@webology @carlton This is when I realize (again) how people can have such a hard time getting into web dev.

Learning python is learning one thing. Learning web development is learning 100+ things.

I get databases from a conceptual standpoint, but the managing of databases is done often enough for me to grow back a new foot.

nemecek_f,
@nemecek_f@iosdev.space avatar

@webology @djangonews 🫣🫣🫣

I am not recommending SQLite but I am using it in my read-heavy projects and I am quite happy with it.

It is straightforward, easy to backup and restore. Postgres is quite intimidating and last time I did Ubuntu upgrade I had to somehow upgrade the Postgres cluster and I had no idea what was happening.

Managed DB is different story but the cost is quite high for hobby projects.

webology,
@webology@mastodon.social avatar

@nemecek_f @djangonews I think read-only projects are a valid use-case for SQLite and I'm not saying to never use it.

I see companies like Fly.io encouraging people to use it (they aren't alone), but they don't even have clear docs for how to set the persistent volume.

I use a Managed DB after years of running my own Postgres boxes and I totally agree with your point. I use a few Managed Postgres boxes for a few dozen projects and it's quite cheap for this scale.

webology,
@webology@mastodon.social avatar

@nemecek_f @djangonews Thankfully, with Postgres everything you mentioned there is plenty of docs on the internet and forms of free support to walk people through.

There really aren't any good guides to getting Django + SQLite running in production that can actually withstand a strong breeze, let alone an orange website visit.

nemecek_f,
@nemecek_f@iosdev.space avatar

@webology @djangonews I should probably look into managed solution even to just be familiar with it.

I think maybe folks often have one managed DB for multiple projects or is that bad practice? Because this for me would be huge cost difference.

Another thing is that my projects are in multiple Digital Ocean datacenters which is probably fail on my part 😅

webology,
@webology@mastodon.social avatar

@nemecek_f I'm happy with DO's managed service even if the company makes me grumpy. Every few years, I half my bill with new droplets, and they somehow creep back up in price until I half them again.

I use two managed DBs mostly because I have one in an org and the other is in my account. They handle backups, upgrades, and everything is painless so far. I need to spend an hour and write some "copy from production" scripts so I have those in case they ever go belly up.

carlton,
@carlton@fosstodon.org avatar

@webology @nemecek_f I should write this up (too 😅) but a mini AWS RDS is like €8/month. If you prepay a year you can get half off that. You can run multiple projects on the same server (hobby or not) and scale up if that ever becomes needed.

I don’t see that as pricey if we’re honest.

It’s a few bucks a month for a DB admin to set it up and run it for you, plus they throw in a DB, and backups, and updates. 🤷‍♀️

(AWS may not be you thing but it generalises.)

webology,
@webology@mastodon.social avatar

@carlton @nemecek_f This is another article I would read. Nodding along because I have similar thoughts with so much value for such little cost. (I think mine are $15 a month)

I use DO because my droplets are already there, but I plan to eventually move over to Crunchy Data (good people there)

josh,
@josh@joshthomas.dev avatar

@webology @carlton @nemecek_f Crunchy on AWS for the smallest hobby tier is like $9, so not nothing/free but reasonable for what you get.

carlton,
@carlton@fosstodon.org avatar

@josh @webology @nemecek_f if I’m a hobbyist, I get quite a few projects on that one instance though, so I reckon it rounds to free 😜

markwalker,
@markwalker@fosstodon.org avatar

@carlton @webology @nemecek_f completely agree with this.

After a decade of running RDS instances I've never had issues with the service. Only minor annoyance with the ability to set config bits, but then you just learn to live with them. Their serverless stuff is very neat as well if you can afford the performance vs cost you get from scaling to zero.

nemecek_f,
@nemecek_f@iosdev.space avatar

@carlton @webology my thinking was that DB by Digital Ocean costs 15$ at a minimum, so per project that would be perhaps 60$ month + the droplets.

I hope to pay this once my projects are bit further along, but I also pay Sentry, domains, backup space so it unfortunately isn't insignificant cost for me.

carlton,
@carlton@fosstodon.org avatar

@nemecek_f @webology you should be able to route multiple projects to the same DB server, each using a different named DB.

nemecek_f,
@nemecek_f@iosdev.space avatar

@carlton @webology right but I need the droplets in the same data center right? otherwise the latency will be a problem?

carlton, (edited )
@carlton@fosstodon.org avatar

@nemecek_f @webology i don’t know my way round DO but they have some equivalent of Availability Zones yes? To begin stick ‘em in one is the simplest.

(It’s not sensible to both do something else and also worry about trying to cut small sums from your hosting bill.)

webology,
@webology@mastodon.social avatar

@carlton @nemecek_f DO's Managed DB has its own connection pooler/proxy/PgBouncer-like tool, which takes the edge off those connection handshakes. That's good enough.

Plus, DO's data centers are all linked over a fast, low-latency backbone.

Think of it this way: their data centers have a lower latency over their backbone than we have from our homes to any of their datacenters.

webology,
@webology@mastodon.social avatar

@carlton @nemecek_f One feature that Crunchy Data has that I haven't seen anyone else support is really good Tailscale support.

I run Tailscale on my droplets with only port 443 open (or even no ports open) and that avoids 99.9...% of most security issues My web droplets can connect to my db droplet over Tailscale and I can Tailscale SSH from a trusted device.

carlton,
@carlton@fosstodon.org avatar

@nemecek_f @webology also though, for essentially read-only workloads SQLite IS totally fine. It’s not you can’t use it. You’re just spending a token doing so.

nemecek_f,
@nemecek_f@iosdev.space avatar

@carlton @webology I will wait for the blog articles and then see what it entails 😆

One of the nice things about SQLite is that I can just copy it to my machine in seconds and have the same data to work on.

So I think I would be spending more tokens with the Postgres but since you both have tons more experince with this than me, I think give it a few months and I will be like "you were right! How to migrate SQLite do managed Postgres?" 😜

webology,
@webology@mastodon.social avatar

@nemecek_f @carlton I look forward to Carlton's article too. 🤣

Django Ninja has hit a sweet spot for me, mostly for quickly copying data from one machine to another. I might draft how I'm doing that for Django News Jobs and an occasional client project.

carlton,
@carlton@fosstodon.org avatar

@webology @nemecek_f “innovation tokens” Jeff 😜

🎁

webology,
@webology@mastodon.social avatar

@carlton @nemecek_f I get a bunch back by using Managed Postgres 🤣

ModelSchema's are a trip though... I still prefer DRF but for quick Django model to json and back to a Django model they are something else.

https://django-ninja.dev/guides/response/django-pydantic/

carlton,
@carlton@fosstodon.org avatar
carlton,
@carlton@fosstodon.org avatar

@nemecek_f For your sites, I very much imagine they’re almost entirely read-driven, so you might not change at all. Multiple users doing multiple writes? Machine driven (i.e. fast) writes? Access from multiple servers? … — Any of those reasons. Anyhoo…. 😗

//@webology

paulox,
@paulox@fosstodon.org avatar

@webology @nemecek_f @djangonews same for me. I use managed PostgreSQL on DO and it works very well for a lot of different use cases. 👍

paulox,
@paulox@fosstodon.org avatar

@nemecek_f @webology @djangonews I wrote a series of articles on how to upgrade you PostgreSQL cluster after an Ubuntu upgrade.
Here's the latest article:
https://www.paulox.net/2023/04/27/upgrading-postgresql-from-version-14-to-15-on-ubuntu-23-04-lunar-lobster/

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • everett
  • DreamBathrooms
  • khanakhh
  • InstantRegret
  • ngwrru68w68
  • magazineikmin
  • mdbf
  • thenastyranch
  • Youngstown
  • rosin
  • slotface
  • tacticalgear
  • kavyap
  • tester
  • megavids
  • cubers
  • osvaldo12
  • GTA5RPClips
  • Durango
  • cisconetworking
  • Leos
  • ethstaker
  • anitta
  • normalnudes
  • modclub
  • provamag3
  • JUstTest
  • lostlight
  • All magazines