Skip to content

Instantly share code, notes, and snippets.

View kovyrin's full-sized avatar

Oleksiy Kovyrin kovyrin

View GitHub Profile
top - 17:00:14 up 10 days, 19:16, 1 user, load average: 18.24, 12.78, 8.37
Tasks: 293 total, 1 running, 292 sleeping, 0 stopped, 0 zombie
Cpu(s): 5.9%us, 1.0%sy, 0.0%ni, 70.4%id, 22.4%wa, 0.0%hi, 0.3%si, 0.0%st
Mem: 12290336k total, 12247644k used, 42692k free, 21052k buffers
Swap: 8387252k total, 6916652k used, 1470600k free, 4098076k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
12155 nobody 15 0 612g 10g 3.9g S 97.3 88.9 7423:18 varnishd
12146 root 15 0 106m 81m 80m S 0.0 0.7 0:00.04 varnishd
4967 root 18 0 162m 48m 1728 D 1.4 0.4 19:33.70 chef-client
[root@html-cache04 ~]# /opt/varnish/bin/varnishstat -1
client_conn 80132379 86.09 Client connections accepted
client_drop 0 0.00 Connection dropped, no sess/wrk
client_req 80112815 86.07 Client requests received
cache_hit 62089531 66.71 Cache hits
cache_hitpass 0 0.00 Cache hits for pass
cache_miss 18023522 19.36 Cache misses
backend_conn 21460 0.02 Backend conn. success
backend_unhealthy 0 0.00 Backend conn. not attempted
backend_busy 0 0.00 Backend conn. too many
[root@html-cache04 ~]# free -m
total used free shared buffers cached
Mem: 12002 11965 37 0 3 4143
-/+ buffers/cache: 7817 4184
Swap: 8190 6610 1580
/opt/varnish/sbin/varnishd \
-a :8080 \
-T localhost:6082 \
-P /var/run/varnish.pid \
-w 20,100,300 \
-s file,/varnish/disk1,120000M \
-s file,/varnish/disk2,120000M \
-s file,/varnish/disk3,120000M \
-s file,/varnish/disk4,120000M \
-s file,/varnish/disk5,120000M \
#--------------------------------------------------------------
# Networking setup
#
net.ipv4.ip_forward = 1
net.ipv4.conf.default.rp_filter = 0
net.ipv4.conf.default.accept_source_route = 0
kernel.core_uses_pid = 1
net.ipv4.ip_local_port_range = 1024 65000
#
# не тестировал этот код, просто адаптировал то, что у нас тут уже есть в скрибде
#
#-----------------------------------------------------------------------------------
#
# Положить это в initializers/something.rb
#
module SimpleShardingMethods
def db_for_key(key, &block)
return on_db(:my_first_db, &block) if key == 1
#
# Где-нить в initializers/sharding.rb
#
module DbCharmer
module Sharding
module Method
class MyCoolMethod
def initialize(config)
# тут можно что-то достать из config[]
end
George Bush, Queen Elizabeth, and Vladimir Putin all die and go to hell. While there, they spy a red phone and ask what the phone is for. The devil tells them it is for calling back to Earth.
Putin asks to call Russia and talks for 5 minutes. When he is finished the devil informs him that the cost is a million rubles, so Putin writes him a check.
Next Queen Elizabeth calls England and talks for 30 minutes. When she is finished the devil informs her that the cost is 6 million pounds, so she writes him a check.
Finally George Bush gets his turn and talks for 4 hours. When he is finished the devil informs him that the cost is $5.00.
When Putin hears this he goes ballistic and asks the devil why Bush got to call the USA so cheaply.
The devil smiles and replies: "Since Obama took over, the country has gone to hell, so it's a local call."
# Default TTL and grace
set obj.grace = 604800s;
set obj.ttl = 604800s;
# For really young (last-modified < 15 min ago) objects, use lower (1 min) ttl
if (obj.http.Last-Modified) {
C{
#include <sys/time.h>
struct timeval tv;
diff --git a/site-cookbooks/scribd_thrift/recipes/default.rb b/site-cookbooks/scribd_thrift/recipes/default.rb
index 9df8464..a374cb4 100644
--- a/site-cookbooks/scribd_thrift/recipes/default.rb
+++ b/site-cookbooks/scribd_thrift/recipes/default.rb
@@ -31,7 +31,7 @@ bash "checkout_thrift" do
cwd "/usr/src"
code <<-EOH
rm -rf thrift
- svn co http://svn.apache.org/repos/asf/incubator/thrift/trunk thrift
+ svn co http://svn.apache.org/repos/asf/incubator/thrift/branches/0.2.x thrift