Skip to content

Instantly share code, notes, and snippets.

View nickva's full-sized avatar

Nick Vatamaniuc nickva

  • USA
View GitHub Profile
@nickva
nickva / topn_view.py
Created March 26, 2025 17:11
Try out topN/bottomN built-in reducers
#!/usr/bin/env python
# ./just_view.py 500 1000
import sys
import time
import random
import requests
TIMEOUT=120
@nickva
nickva / bench_config.erl
Created February 27, 2025 23:22
Quick and dirty concurrent config get benchmark for CouchDB
% Save in ./couchdb top level
%
% $ ./dev/run ...
% $ remsh
%
% > bench_config:go(1000000, 100).
% #{max => 5.620738,min => 0.62035,total => 5633922,
% avg => 3.82163797,p50 => 4.568493,p75 => 5.314903,
% p90 => 5.519178}
%
#!/bin/bash
# ./dev/run --admin=adm:pass -n1
# "http" is httpie (https://httpie.io)
DB=http://adm:[email protected]:15984
http -q delete $DB/db
http -q put $DB/db
@nickva
nickva / purge.sh
Created February 19, 2025 16:26
check purge infos endpoint
#!/bin/sh
# ./dev/run --admin=adm:pass -n1
# "http" is httpie (https://httpie.io)
DB=http://adm:[email protected]:15984
http -q delete $DB/db
http -q put $DB/db
@nickva
nickva / just_view.py
Created February 16, 2025 06:09
CouchDB fill a db with docs and run a view
#!/usr/bin/env python
# ./just_view.py 500 1000
import sys
import time
import requests
TIMEOUT=120
AUTH=('adm','pass')
@nickva
nickva / replicate_att.sh
Created February 7, 2025 02:47
CouchDB replicate attachment twice
#!/bin/sh
# Create test DBs
echo "***** SETTING UP DBS *****"
curl -s -XDELETE 'http://adm:pass@localhost:15984/source'
curl -s -XDELETE 'http://adm:pass@localhost:15984/target'
curl -s -XPUT 'http://adm:pass@localhost:15984/source'
echo '{
@nickva
nickva / k6_couchdb_constant_arrival.js
Created February 4, 2025 15:12
CouchDB K6 script
//
// Examples:
// 1) Run all secenarios for 30sec with given user/pass:
// $ BENCH_DURATION=30s BENCH_USER=adm BENCH_PASS=pass run k6.js
// 2) Run just doc_update
// $ BENCH_SCENARIOS=doc_update k6 run $script.js
// 3) Run just doc_get at 10 rps, starting with 25k docs of 64KB each:
// $ BENCH_DOCS=25000 BENCH_SCENARIOS=doc_get BENCH_GET_RATE=10 k6 run $script.js
import http from 'k6/http';
@nickva
nickva / bench.erl
Created January 28, 2025 00:53
Benchmark couch work queue
-module(bench).
-export([main/1]).
producer(Q) ->
receive
{produce, Pid, N, Size} ->
{ok, Dt} = produce(Q, N, erlang:monotonic_time(), Size),
Pid ! {produced, Dt},
producer(Q)
@nickva
nickva / create_and_poll_reps.py
Created October 14, 2024 17:02
Create and monitor Apache CouchDB replication documents
#!/usr/bin/env python
# Run with an n=1 dev/run test cluster
# Needs python 3.7 minimum
#
# $ virtualenv -p python3 venv3
# $ . venv3/bin/activate
# $ pip install requests
# make && ./dev/run -n 3 --with-haproxy --admin=adm:pass
@nickva
nickva / remsh.erl
Last active May 23, 2024 17:09
recon trace return errors only
> recon_trace:calls({fabric, design_docs, fun(_) -> exception_trace() end}, 10, [
{formatter, fun
({trace, _, exception_from, MFA, Err}) -> io_lib:format("|~p:~p|~n", [MFA,Err]);
({trace, _, return_from, MFA, {IsOk,_}=Res}) when IsOk =/= ok -> io_lib:format("|~p:~p|n", [MFA,Res]);
(_) -> ""
end}
]).