Skip to content

Instantly share code, notes, and snippets.

@rahulwa
rahulwa / ELK_stack.md
Last active May 5, 2021 02:45
TODO in production for ELK stack

TODO in production -

Elasticsearch

  • select large memory instance
    • A machine with 64 GB of RAM is the ideal sweet spot, but 32 GB and 16 GB machines are also common. Less than 8 GB tends to be counterproductive (you end up needing many, many small machines), and greater than 64 GB has problems.
    • In general, it is better to prefer medium-to-large boxes.
  • create swap using instance store disk, not EBS.
  • Disks should be ssd and iops
  • cfq (default I/O Scheduler in *nix) is inefficient for SSD, however, since there are no spinning platters involved. Instead, deadline or noop should be used instead. The deadline scheduler optimizes based on how long writes have been pending, while noop is just a simple FIFO queue.
We couldn’t find that file to show.
## credit: http://fabian-affolter.ch/blog/the-lineinfile-module-of-ansible/
---
- hosts: alpine_install
user: root
tasks:
# - name: create a complete empty file
# command: /usr/bin/touch /test/test.conf
- name: create a new file with lineinfile
@rahulwa
rahulwa / postgres_queries_and_commands.sql
Last active September 18, 2018 19:09 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (9.2)
SELECT pid, age(query_start, clock_timestamp()), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- kill running query
SELECT pg_cancel_backend(procpid);
-- kill idle query
@rahulwa
rahulwa / restaurant_website.py
Created July 16, 2017 16:54
github.com/lobrown/Full-Stack-Foundations/master/Lesson-2/Objective-5-Solution/webserver.py
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
import cgi
# import CRUD Operations from Lesson 1 ##
from database_setup import Base, Restaurant, MenuItem
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
# Create session and connect to DB ##
engine = create_engine('sqlite:///restaurantmenu.db')
★ Install of core/ffmpeg/3.3.2/20170710172745 complete with 0 new packages installed.
crawler-development: Resolved dependency 'core/ffmpeg' to /hab/pkgs/core/ffmpeg/3.3.2/20170710172745
crawler-development: WARN
crawler-development: WARN The following runtime dependencies have more than one version
crawler-development: WARN release in the full dependency chain:
crawler-development: WARN
crawler-development: WARN * core/gmp ( core/gmp/6.1.0/20170513202112 core/gmp/6.1.2/20170526062114 )
crawler-development: WARN
crawler-development: WARN The current situation usually arises when a Plan has a direct
crawler-development: WARN dependency on one version of a package (`acme/A/7.0/20160101200001`)
@rahulwa
rahulwa / pyconfig.py
Created June 5, 2018 17:51
Wrapper over Consul in Python for configuration management.
import requests
import os
import logging
import sys
import json
import base64
class Conf:
'''
Wrapper on top of consul api to facilitates configuration for Application.
--- MEMORY RELATED
--- wal_buffer
SHOW wal_buffers;
SELECT name,setting,unit,current_setting(name) FROM pg_settings WHERE name='wal_buffers';
--- unix: `getconf PAGE_SIZE``getconf _PHYS_PAGES` ... Linux: `ipcs -l` `sysctl kernel.sem`
--- initial parameters of PostgreSQL: https://pgtune.leopard.in.ua/#/
create extension pg_buffercache;
\dx pg_buffercache
--- pg_buffercache has several columns
--- bufferid, the block ID in the server buffer cache
@rahulwa
rahulwa / kafka-cheat-sheet.md
Last active November 20, 2018 08:43 — forked from ursuad/kafka-cheat-sheet.md
Quick command reference for Apache Kafka

Kafka Topics

List existing topics

bin/kafka-topics.sh --zookeeper localhost:2181 --list

Describe a topic

bin/kafka-topics.sh --zookeeper localhost:2181 --describe --topic mytopic

Create the topic

unset JMX_PORT; bin/kafka-topics.sh --zookeeper X:2181 --create --topic NAME --replication-factor 3 --partitions 3

Purge a topic