Browse Source

added sqlite blog post

theming
Will Webberley 2 months ago
parent
commit
0c6e5168bc
7 changed files with 70 additions and 28 deletions
  1. 2
      README.md
  2. 44
      gatsby-config.js
  3. 12
      src/components/Layout/Layout.css
  4. 2
      src/pages/blog/2021-01-03-scaling-serverless.md
  5. 2
      src/pages/blog/2021-01-30-moving-to-gitea.md
  6. 36
      src/pages/blog/2021-02-01-why-not-sqlite.md
  7. BIN
      static/media/blog/sqlite.jpg

2
README.md

@ -2,6 +2,8 @@
The source for my personal website. The site is currently live at [https://wilw.dev](https://wilw.dev).
This project doesn't really come with a licence. The site content itself is by me (and therefore probably copyrighted somewhat), but feel free to use the code itself for your own needs.
## Developing
1. Clone and change into the repository

44
gatsby-config.js

@ -20,7 +20,7 @@ const rssPostQuery = `
}
}
`;
const createRssPost = edge => {
const createRssPost = (edge, site) => {
const { node } = edge;
const { slug } = node.fields;
return Object.assign({}, edge.node.frontmatter, {
@ -63,55 +63,47 @@ module.exports = {
`,
feeds: [
{
serialize: ({ query: { allMarkdownRemark } }) => allMarkdownRemark.edges.map(createRssPost),
serialize: ({ query: { site, allMarkdownRemark } }) => allMarkdownRemark.edges.map(e => createRssPost(e, site)),
query: rssPostQuery,
output: "/rss.xml",
title: "Will Webberley's Blog",
description: 'A collection of all of my notes and posts.'
},
{
serialize: ({ query: { allMarkdownRemark } }) => {
allMarkdownRemark.edges.filter(edge => {
const tags = edge.node.frontmatter.tags;
return tags && tags.length > 0 && tags.indexOf('book') > -1;
}).map(createRssPost)
},
serialize: ({ query: { site, allMarkdownRemark } }) => allMarkdownRemark.edges.filter(edge => {
const tags = edge.node.frontmatter.tags;
return tags && tags.length > 0 && tags.indexOf('book') > -1;
}).map(e => createRssPost(e, site)),
query: rssPostQuery,
output: "/books.xml",
title: "Will Webberley's Blog: Books",
description: 'A collection of notes and posts about books.'
},
{
serialize: ({ query: { allMarkdownRemark } }) => {
allMarkdownRemark.edges.filter(edge => {
const tags = edge.node.frontmatter.tags;
return tags && tags.length > 0 && tags.indexOf('technology') > -1;
}).map(createRssPost)
},
serialize: ({ query: { site, allMarkdownRemark } }) => allMarkdownRemark.edges.filter(edge => {
const tags = edge.node.frontmatter.tags;
return tags && tags.length > 0 && tags.indexOf('technology') > -1;
}).map(e => createRssPost(e, site)),
query: rssPostQuery,
output: "/technology.xml",
title: "Will Webberley's Blog: Technology",
description: 'A collection of notes and posts about technology.'
},
{
serialize: ({ query: { allMarkdownRemark } }) => {
allMarkdownRemark.edges.filter(edge => {
const tags = edge.node.frontmatter.tags;
return tags && tags.length > 0 && tags.indexOf('life') > -1;
}).map(createRssPost)
},
serialize: ({ query: { site, allMarkdownRemark } }) => allMarkdownRemark.edges.filter(edge => {
const tags = edge.node.frontmatter.tags;
return tags && tags.length > 0 && tags.indexOf('life') > -1;
}).map(e => createRssPost(e, site)),
query: rssPostQuery,
output: "/life.xml",
title: "Will Webberley's Blog: Life",
description: 'A collection of notes and posts about everyday life.'
},
{
serialize: ({ query: { allMarkdownRemark } }) => {
allMarkdownRemark.edges.filter(edge => {
const tags = edge.node.frontmatter.tags;
return tags && tags.length > 0 && tags.indexOf('technology') === -1;
}).map(createRssPost)
},
serialize: ({ query: { site, allMarkdownRemark } }) => allMarkdownRemark.edges.filter(edge => {
const tags = edge.node.frontmatter.tags;
return tags && tags.length > 0 && tags.indexOf('technology') === -1;
}).map(e => createRssPost(e, site)),
query: rssPostQuery,
output: "/nontech.xml",
title: "Will Webberley's Blog: Non-Tech",

12
src/components/Layout/Layout.css

@ -91,6 +91,18 @@ article .caption{
margin-top:-45px;
font-style:italic;
}
article blockquote{
border-left: 10px solid wheat;
padding: 10px;
background: seashell;
font-family: 'Recursive', monospace;
--mono: "MONO" 0; /* 0-1 */
--casl: "CASL" 0.8; /* 0-1 */
--wght: "wght" 400;
--slnt: "slnt" -10; /* 0 - -15 */
--CRSV: "CRSV" 1;
font-variation-settings: var(--mono), var(--casl), var(--wght), var(--slnt), var(--CRSV);
}
code{
font-family: 'Recursive', monospace;

2
src/pages/blog/2021-01-03-scaling-serverless.md

@ -2,7 +2,7 @@
date: "2021-01-03T17:00:00Z"
title: "Scaling serverless apps: some lessons learned"
description: "Potential pitfalls in writing serverless apps for AWS Lambda, Google Cloud Functions and Cloudflare Workers."
tags: [100daystooffload, serverless, aws, lambda, analysis, technology]
tags: [100daystooffload, serverless, aws, lambda, analysis, technology, opinion]
---
Building apps on serverless architecture has been a game-changer for me and for developers everywhere, enabling small dev teams to cheaply build and scale services from MVP through to enterprise deployment.

2
src/pages/blog/2021-01-30-moving-to-gitea.md

@ -2,7 +2,7 @@
date: "2021-01-30T15:31:00Z"
title: "Out with the Old: Moving to Gitea"
description: "Why and how I moved from using GitHub to a self-hosted Gitea service."
tags: [selfhosted, 100daystooffload, gitea, github, analysis, technology]
tags: [selfhosted, 100daystooffload, gitea, github, analysis, technology, opinion]
---
If you've visited my geminispace ([gemini://g.wilw.dev](gemini://g.wilw.dev)) you'll have noticed that I've recently been on a mission to decentralise the every-day tools and services I use, and will understand the reasons why. This post will likely become part of a series of posts in which I talk about taking control and responsibility for my own data.

36
src/pages/blog/2021-02-01-why-not-sqlite.md

@ -0,0 +1,36 @@
---
date: "2021-02-01T21:06:00Z"
title: "Why not SQLite?"
description: "An open-ended post about why (or why not) use SQLite in your projects rather than a fully-fledged DBMS server."
tags: [100daystooffload, technology, opinion]
---
If you need a database for your next project, why not first consider if [SQLite](https://sqlite.org) might be a good option? And I don't mean just for getting an MVP off the ground or for small personal systems; I mean for "real" production workloads.
![Why not Sqlite?](/media/blog/sqlite.jpg)
Many people will be quick to jump on this with chimes of "it's not designed for production", but I think it depends on what is actually _meant_ by "production"? Sure, it's not the right choice for every scenario - it wouldn't work well in distributed workloads or for services expected to receive a very high volume of traffic - but it has been used successfully in many real-world cases.
What made me feel the need to write this article was seeing this sentence in the [README of the Synapse Docker repo](https://hub.docker.com/r/matrixdotorg/synapse/):
> By default it uses a sqlite database; for production use you should connect it to a separate postgres database. - [matrixdotorg/synapse](https://hub.docker.com/r/matrixdotorg/synapse/)
Don't get me wrong. I totally get its meaning, but at the same time do personal Matrix servers or [home Nextcloud servers](https://help.nextcloud.com/t/nextcloud-and-sqlite/34304) not count as "production"?
[Pieter Levels](https://levels.io) famously used SQLite to help drive revenues from some of his products to [well over six-digit dollar values](https://www.nocsdegree.com/pieter-levels-learn-coding), and SQLite's [own 'appropriate uses' list](https://www.sqlite.org/whentouse.html) explains where it can be useful:
> SQLite works great as the database engine for most low to medium traffic websites (which is to say, most websites) - [sqlite.org](https://www.sqlite.org/whentouse.html)
Even if your site or service does eventually outgrow SQLite (which will be a nice problem to have), your application code will still be using SQL and so it should be relatively easy to migrate to something like [PostgreSQL](https://www.postgresql.org).
As [Paul Graham said](http://paulgraham.com/ds.html), "do things that don't scale".
Of course, it is backed by disk and so is subject to the usual I/O constraints applicable to any file, but nearly all VPS providers offer SSD-backed instances these days and SQLite [claims to be faster than filesystem I/O](https://sqlite.org/fasterthanfs.html) anyway.
It's worth remembering that there can be huge overheads and costs in setting up "production-ready" database servers. You'll need to think about provisioning the instance itself, installation of dependencies, certificates, the usual networking hardening (firewalls, ports, etc.) - and then keeping all of this up-to-date too. Even when using managed database services there are still user roles, authentication and rotating credentials to worry about, along with securely provisioning your applications with the connection strings.
Having all of these things to worry about carries the additional risk of encouraging people to become lazy or to not have the time needed to make sure everything is done properly; an easy way to accidentally introduce security issues. Plus, if you have multiple environments (e.g. for staging or testing) then these factors, and the associated costs, amplify.
There is also some interesting discussion on the topic in this [Hacker News thread](https://news.ycombinator.com/item?id=23281994) from last year.
I just think it's definitely worth a go before jumping straight into alternative heavier options. It's free, has a [smaller footprint](https://sqlite.org/footprint.html), has easily accessible bindings for many languages, and you can get started in minutes - [all you need is a file](https://sqlite.org/onefile.html).

BIN
static/media/blog/sqlite.jpg

Before After
Width: 620  |  Height: 473  |  Size: 64 KiB
Loading…
Cancel
Save