Skip to content

Instantly share code, notes, and snippets.

View lacoski's full-sized avatar
😀
An Introvert Engineer

Nguyễn Bá Thành lacoski

😀
An Introvert Engineer
View GitHub Profile
@lacoski
lacoski / forms.py
Created October 7, 2018 14:25 — forked from artschwagerb/forms.py
Django Forms Example
from django import forms
from inventory.models import Computer
class ComputerForm(forms.ModelForm):
class Meta:
model = Computer
class ChromebookForm(forms.ModelForm):
# Rootユーザに変更
sudo su -
# virtualenvインストール
pip install -U virtualenv
virtualenv /www/sentry/
source /www/sentry/bin/activate
@lacoski
lacoski / settings.py
Created November 25, 2018 05:15 — forked from alexmorozov/settings.py
Production raven config
INSTALLED_APPS += (
'raven.contrib.django.raven_compat',
)
MIDDLEWARE_CLASSES += (
'raven.contrib.django.raven_compat.middleware.Sentry404CatchMiddleware',
)
RAVEN_CONFIG = {
'dsn': 'http://x:y@sentry.domain.com/2', # NOQA
@lacoski
lacoski / app.py
Created December 29, 2018 01:32 — forked from dims/app.py
oslo.config + oslo.log sample
import sys
from oslo.config import cfg
from oslo_log import log as oslo_logging
CONF = cfg.CONF
CONF.register_opt(cfg.StrOpt('NODE_NAME'), cfg.OptGroup('HA'))
def main():
oslo_logging.register_options(CONF)
CONF(sys.argv[1:], default_config_files=['app.conf'])
@lacoski
lacoski / bench.py
Created January 1, 2019 15:01 — forked from methane/bench.py
Benchmarking MySQL drivers (Python 3.4)
from __future__ import print_function
import time
def query_10k(cur):
t = time.time()
for _ in range(10000):
cur.execute("SELECT 1,2,3,4,5")
res = cur.fetchall()
assert len(res) == 1
assert res[0] == (1,2,3,4,5)
@lacoski
lacoski / celery.sh
Created January 29, 2019 04:33 — forked from amatellanes/celery.sh
Celery handy commands
/* Useful celery config.
app = Celery('tasks',
broker='redis://localhost:6379',
backend='redis://localhost:6379')
app.conf.update(
CELERY_TASK_RESULT_EXPIRES=3600,
CELERY_QUEUES=(
Queue('default', routing_key='tasks.#'),
@lacoski
lacoski / Repeat.scala
Created February 13, 2019 07:21 — forked from maiha/Repeat.scala
gatling: repeat example
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import io.gatling.jdbc.Predef._
class Repeat extends Simulation {
val httpProtocol = http.baseURL("http://localhost").inferHtmlResources()
val scn = scenario("repeat test").repeat(10) { exec(http("Home").get("/")) }
setUp(scn.inject(rampUsers(10) over(1)).protocols(httpProtocol))
}
@lacoski
lacoski / RecordedSimulation.scala
Last active February 17, 2019 15:39
Ví dụ sử dụng Gatling.io Cloud365
import scala.concurrent.duration._
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import io.gatling.jdbc.Predef._
class RecordedSimulation extends Simulation {
val httpProtocol = http
.baseUrl("http://10.10.10.86")
@lacoski
lacoski / nginx-tuning.md
Created June 5, 2019 07:22 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@lacoski
lacoski / gist:9974c0a26686fb50f93ae3a0a64c12c3
Created June 5, 2019 16:57 — forked from luckydev/gist:b2a6ebe793aeacf50ff15331fb3b519d
Increate max no of open files limit in Ubuntu 16.04/18.04 for Nginx
# maximum capability of system
user@ubuntu:~$ cat /proc/sys/fs/file-max
708444
# available limit
user@ubuntu:~$ ulimit -n
1024
# To increase the available limit to say 200000
user@ubuntu:~$ sudo vim /etc/sysctl.conf