Native prerequisites

  • Running Weer natively requires Node.js, Yarn, Postgres, Redis, and PM2. 56:49
  • Docker installed those automatically, but native deployment requires installing and managing them manually. 56:49 57:06

Version selection

  • The speaker uses official installation instructions for each technology. 57:19
  • For Node.js, the tutorial uses the LTS version because LTS releases are supported for years, while current releases may be supported only for months. 57:19 57:40
  • NVM is used to install and switch Node versions, comparable to SDKMAN for Java. 58:15 58:36
  • Ubuntu apt packages can lag behind latest upstream major versions; this is why some installations add official repositories before installing. 59:23 1:02:11
  • The speaker emphasizes keeping server software current because known vulnerabilities in old versions are commonly exploited. 1:03:18 1:03:32

Postgres, Redis, and PM2

  • Postgres is installed, checked with systemctl status, and assigned a password for the default postgres user. 1:03:47 1:04:17 1:04:46
  • Redis is installed from official instructions rather than relying on an older default package. 1:05:22 1:06:06
  • Redis is verified with redis-cli, including a simple set/get test and version check. 1:07:11 1:07:41
  • PM2 is installed globally with npm and is used to run Node.js processes, restart them, and manage them in the background. 1:07:41 1:08:19
  • The same Postgres and Redis installations can be reused by the other applications deployed later. 1:08:34

Build and start Weer

  • After installing prerequisites, disk usage increased by only a few hundred megabytes. 1:09:13
  • The production setup path is yarn setup, then yarn start. 1:09:30 1:09:49
  • yarn setup installs dependencies, builds packages, creates the Weer database, creates tables, seeds data, and flushes Redis. 1:09:49 1:11:14 1:11:57
  • The .env file must include the Postgres password chosen during installation. 1:10:46
  • Native deployment used about 5 GB after setup, compared with about 6 GB in the Docker path. 1:11:57 1:12:15
  • yarn start runs the app through PM2, and pm2 logs is needed to see runtime logs. 1:12:15 1:12:35

Runtime behavior

  • PM2 runs two server instances plus one janitor instance. 1:13:01
  • Node applications need cluster mode to better use available CPU cores because requests are initially handled through a single-threaded model. 1:13:17 1:13:33
  • Java and Rust applications usually do not follow this Node cluster pattern because their runtimes/frameworks handle threading differently. 1:13:17

Inspecting Redis and Postgres

  • Redis Insight can connect to the server's Redis through an SSH tunnel. 1:13:54 1:14:19
  • Visiting a shortened link creates a view record in the Redis stream with fields such as user agent, link type, and QR-code indicator. 1:17:30 1:17:50
  • The janitor drains the Redis stream and inserts views into Postgres in batches, then acknowledges the processed stream entries. 1:18:14 1:18:30 1:18:56
  • The stream max length is configured as 100,000, allowing Redis to truncate when it reaches that size. 1:18:56
  • Postgres can be inspected from the command line or with pgAdmin through an SSH tunnel. 1:19:22 1:20:13