Skip to main content

Posts

Showing posts from February, 2016

Apache ton of vhost log

1 page view x 200-300 request (get các item con của trang). 1 line trong vhost log dài tầm 4-5 dòng bình thường, bao gồm thông tin client, browser, ip... thông tin resource request như file css, js hay ảnh ... 1000 line log ~ 380KB vì 1000 ~ 4000 đến 5000 bình thường ( 80 ký tự 1 dòng chẳng hạn). => 10k view thì tốn 380KB x 10 = 3.8 MB Nhưng do 1 page view = 200-300 request con nên phải nhân lên 250 lần (tính trung bình) => log thực tế cho 10k view là 250x3.8MB ~ 1GB log Đúng như thực tế . Thực tế 20k page view => 1.7GB log.gz (không biết nhầm hay ko) nhưng nén rồi mà vẫn 1.7GB thì khó hiểu. Có thể file to quá nên GZ bỏ qua nén luôn. http://stackoverflow.com/questions/18761239/apache-server-reached-maxclients-setting-consider-raising-the-maxclients-settin

Config git access server over ssh

Note lại cấu hình git ssh key: Host psi.server     HostName 19.54.19.38     User server_acc_name     IdentityFile ~/.ssh/id_rsa_kkk     Port 22     TCPKeepAlive yes     IdentitiesOnly yes Host bitbucket.org     Hostname bitbucket.org     IdentityFile ~/Dropbox/FRL/config/id_rsa_bit     TCPKeepAlive yes     IdentitiesOnly yes

Apache KeepAlive

Advantages of KeepAlive Improves website speed : It reduces latency associated with HTTP transfers and delivers a better user experience. Reduces CPU usage : On the server side enabling KeepAlive reduces CPU usage. Consider that a typical web page has dozens of different files such as images, stylesheets, javascript files etc. If KeepAlive is disabled a separate connection must be made for each of those files. Creating and closing connections has an overhead and doing it for every single file wastes CPU time. Disadvantages of Keepalive Increases memory usage : Enabling KeepAlive  increases memory usage on the server. Apache processes have to keep connections open waiting for new requests from established connections. While they are waiting they are occupying RAM that could be used to service other clients. If you turn off KeepAlive fewer apache processes will remain active. This will lower memory usage and allow Apache to serve more users. When should you enable KeepAlive?

Wrong Index slow down MySQL then kill Server

Bài này m note lại tình huống khi MySQL chiếm dụng CPU do query chậm. Query chậm do đánh Index sai (thừa) cho một bảng khá to cỡ x100K rows. Trạng thái: - Server treo, MySQL chiếm CPU - Apache2 tầm 150 child process - Swap đầy dần lên 70-80% Thông số: VPS giá rẻ 500MB RAM, 1G Swap Traffic và website: ... Quá trình khắc phục: Đầu tiên soi MySQL, show processlist không thấy j (cái này phải đợi nó mới hiện ra). Do show processlist ko có j nên quay ra search tunning Apache mà cái này ít được can thiệp on-fly. Cuối cùng rất may trong 1 lần show processlist nữa thì thấy 1 đống log query đang chờ. => Do 1 bảng liên quan đến lượng view (khi view tăng) thì index nó mới lộ rõ bug. Sau khi xóa index thừa restart thì mọi việc có vẻ ok. Mysql vẫn chiếm CPU khá nhiều tầm 25-55% nhưng swap thì chỉ tầm 100MB/1000MB. Lỗi này xuất hiện 1-2 lần 1 ngày sau khi restart MySQL thì hết. Cho đến 1 hôm thì restart rất nhiều lần và vẫn đơ. Cập nhật: Tổng hợp sau khi theo dõi tiếp thì nguyên n

Git merging vs rebasing

Nhắc lại git merge với rebase. Lâu ko dùng rebase h thử lại đỡ phải thao tác checkout + pull + merge ... https://www.atlassian.com/git/tutorials/merging-vs-rebasing/summary Merging vs. Rebasing The  git rebase  command has a reputation for being magical Git voodoo that beginners should stay away from, but it can actually make life much easier for a development team when used with care. In this article, we’ll compare  git rebase  with the related  git merge command and identify all of the potential opportunities to incorporate rebasing into the typical Git workflow. Conceptual Overview The first thing to understand about  git rebase  is that it solves the same problem as  git merge . Both of these commands are designed to integrate changes from one branch into another branch—they just do it in very different ways. Consider what happens when you start working on a new feature in a dedicated branch, then another team member updates the  master branch with new co