Skip to content

Instantly share code, notes, and snippets.

View ojengwa's full-sized avatar
🏠
Working from home

Bernard Ojengwa ojengwa

🏠
Working from home
View GitHub Profile
@ojengwa
ojengwa / gist:e51ead51ad12b68508d13b95d4ddb391
Created March 6, 2020 20:00 — forked from afair/gist:3803895
PostgreSQL and Pgpool Architecture

Hey! I saw this has been indexed by the search engines. It is a first draft of a post I ended up publishing on my blog at: Scaling PostgreSQL With Pgpool and PgBouncer

Thanks for stopping by!

PostgreSQL and Pgpool Architecture

1. PG-native master-slave achitecture
1. Configure bindings and nodes on Both DB servers
a. Select staging DB as the master (main)
b. Set the prod DB as the slave node (aux)
2. PG automatically propagates and syncs the data between the DBs
3. Add or change data on the staging DB
a. Compare both dataset
b. Update records across both databases to ensure consistency
PROS
@ojengwa
ojengwa / bookshelf-virtual plugin support for strapi models
Created January 29, 2019 14:03
This simple alteration to the strapi-hook-bookshelf package adds support for model virtuals
'use strict';
/**
* Module dependencies
*/
// Core
const path = require('path');
// Public node modules.
@ojengwa
ojengwa / deploy_docs
Last active November 3, 2018 14:49
Ichnaea Deploy docs
## Deployment Guide
Mozilla Ichnaea has two depeendencies:
1. Mysql Server
2. Redis Server
To install, follow the following steps
1. ### Build the required images
1. Pull the custom Mysql Database image from Docker Hub
// const test_array = [{name: "Bernard", ranking: 100}, {name:"Messi", ranking: 1}, {name:"McCain", ranking: 17} ]
function sorted(list){
return list.sort(function(a, b){
return a.ranking - b.ranking;
});
}
function average_ranking(list){
var sum = list.reduce( function(prev_obj, this_obj) { return prev_obj + this_obj.ranking }, 0);

Vertical decomposition. Creating cohesive services

One of the biggest misconceptions about services is that a service is an independent deployable unit, i.e., service equals process. With this view, we are defining services according to how components are physically deployed. In our example, since it’s clear that the backend admin runs in its own process/container, we consider it to be a service.

But this definition of a service is wrong. Rather you need to define your services in terms of business capabilities. The deployment aspect of the system doesn’t have to be correlated to how the system has been divided into logical services. For example, a single service might run in different components/processes, and a single component might contain parts of multiple services. Once you start thinking of services in terms of business capabilities rather than deployment units, a whole world of options open.

What are the Admin UI

@ojengwa
ojengwa / docker-compose2aws
Last active January 18, 2024 17:58
Set by step guide on deploying your docker containers to AWS using docker-compose and docker-machine
# Deploy to AWS using docker-machine and docker-compose
## 1. Prepare your machine
Please follow this steps:
1.1 Install docker in your localhost. [Installation link](https://docs.docker.com/engine/installation/)
1.2 Install docker-machine in your localhost. [Installation link](https://docs.docker.com/compose/install/)
1.3 Install docker-compose in your localhost. [Installation link](https://docs.docker.com/machine/install-machine/)
1.4 Create an account in AWS (skip this step if you already have one). [AWS](https://aws.amazon.com/)
.PHONY: all
assets:
gsutil -m rsync -R <public_dir>/ gs://<bucket_id>/<public_dir>
worker:
gcloud app deploy worker.yaml --stop-previous-version --verbosity=info --promote --project=<project_id>
web:
- What do Etcd, Consul, and Zookeeper do?
- Service Registration:
- Host, port number, and sometimes authentication credentials, protocols, versions
numbers, and/or environment details.
- Service Discovery:
- Ability for client application to query the central registry to learn of service location.
- Consistent and durable general-purpose K/V store across distributed system.
- Some solutions support this better than others.
- Based on Paxos or some derivative (i.e. Raft) algorithm to quickly converge to a consistent state.
- Centralized locking can be based on this K/V store.
let unassigned = realtime.unassigned.child(attrs.body.order_id)
let assigned = realtime.assigned.child(attrs.body.order_id)
unassigned.ref.once('value', (data) => {
data = data.val()
data['status'] = 'assigned'
assigned.set(data, (error) => {
if (!error) {
let champion_ref = realtime.champions.child(attrs.body.champion_id + '/assigned/' + attrs.body.order_id)
champion_ref.set(data, (error) => {