Skip to content

Instantly share code, notes, and snippets.

View filipecosta90's full-sized avatar

Filipe Oliveira (Personal) filipecosta90

View GitHub Profile
@filipecosta90
filipecosta90 / merge_histograms.py
Created January 22, 2023 19:52
Find the percentile of a combined dataset of latency values from two Redis servers
# To find the percentile of a combined dataset of latency values from two Redis servers,
# you would first need to retrieve the latency data from each server and combine it into
# a single dataset.
# Once you have the combined dataset, you can calculate the desired percentile.
import redis
from hdrh.histogram import HdrHistogram
# connect to shard 1
@filipecosta90
filipecosta90 / Radix example for RedisTimeSeries OSS cluster connection
Last active December 14, 2022 01:53
Code snippet addressing question: https://github.com/RedisTimeSeries/redistimeseries-go/issues/63. Usage example (for cluster use --cluster-mode): ./radix-redistimeseries-example --host localhost:20002
package main
import (
"flag"
"fmt"
"github.com/mediocregopher/radix/v3"
"log"
"strconv"
"time"
)
@filipecosta90
filipecosta90 / Go Web Frameworks benchmark. How much load can each system handle?
Last active May 31, 2020 17:17
Go Web Frameworks benchmark. How much load can each system handle?
fco@hpe10:~/go/src/github.com/filipecosta90/go-web-framework-benchmark$ python3 test.py \
--enable-cpu-affinity --wrk-max-cpus 6 --wrk-connections 100 --pipeline-sizes 100 \
--web-framework-processing-time-ms 0 --stress-rps 5000000 --output-file stress-test.json
@filipecosta90
filipecosta90 / nyse_example.sh
Created February 9, 2020 01:28
Stock Charts - Ingesting NYSE Stock Excange real-time data -- https://groups.google.com/d/msg/redistimeseries/ZhfKKqk66FY/YybDqf72AwAJ
#!/bin/bash
######################
# time-series creation
######################
# https://oss.redislabs.com/redistimeseries/commands/#tscreate
redis-cli ts.create nyse_AAPL_price RETENTION 120000 LABELS metric price name APPL
redis-cli ts.create nyse_GOOGL_price RETENTION 120000 LABELS metric price name GOOGL
redis-cli ts.create nyse_MSFT_price RETENTION 120000 LABELS metric price name MSFT
redis-cli ts.create nyse_APPL_size RETENTION 120000 LABELS metric size name APPL
@filipecosta90
filipecosta90 / bcc_ubuntu
Last active March 24, 2023 16:34
Ubuntu Ansible Playbook to Install BCC (BPF Compiler Collection) Package Upstream Stable
---
- name: Install BCC (BPF Compiler Collection) Package Upstream Stable
hosts: all
connection: ssh
become: yes
become_user: root
become_method: sudo
vars:
- bccpath: '/usr/share/bcc/tools'
@filipecosta90
filipecosta90 / redis_subscriber.py
Created December 1, 2019 00:14
Module and script to parse pub-sub events and write them to Redis hashes.
#!/usr/bin/env python
"""Module and script to parse pub-sub events and write them to Redis hashes."""
import json
import redis
from wikiutils import current_timestamp, pubsub_channel, redis_url
r = redis.Redis.from_url(redis_url)
@filipecosta90
filipecosta90 / redis_publisher.py
Created November 30, 2019 23:40
Module and script to forward events from wikimedia stream to Redis pub-sub.
#!/usr/bin/env python
"""Module and script to forward events from wikimedia stream to Redis pub-sub."""
import asyncio as aio
import json
import aioredis
from aiohttp_sse_client import client as sse_client
from wikiutils import pubsub_channel, redis_url
@filipecosta90
filipecosta90 / run-redis-benchmark.sh
Last active April 26, 2019 12:04
script to run redis benchmark with different payload, pipeline, and iothreads, saving the ouput to distinct files
#!/bin/bash
# script to run redis benchmark with different payload, pipeline, and iothreads ( the iothreads are configured on the redis-server VM
# and that argument is only for creating a different file for different redis-server configs
args=("$@")
n=${args[0]}
h=${args[1]}
iothreads=${args[2]}
dir=${args[3]}
fcosta_oliveira@n1-highcpu-96-redis-server-1:~/STREAM$ ./stream.100M
-------------------------------------------------------------
STREAM version $Revision: 5.10 $
-------------------------------------------------------------
This system uses 8 bytes per array element.
-------------------------------------------------------------
Array size = 100000000 (elements), Offset = 0 (elements)
Memory per array = 762.9 MiB (= 0.7 GiB).
Total memory required = 2288.8 MiB (= 2.2 GiB).
Each kernel will be executed 10 times.
@filipecosta90
filipecosta90 / script.sh
Created April 3, 2019 08:13
RedisGears CDN Sample - helper script
#!/bin/bash -x
redis-cli flushall
redis-cli module load /Users/filipeoliveira/redis-porto/RedisGears/redisgears.so
redis-cli module load /Users/filipeoliveira/redis-porto/RedisTimeSeries/src/redistimeseries.so
# Register for new cdn events
redis-cli -x rg.pyexecute < imageserver.py
# Load sample images into cdn:* keys