Feb 27, 2013

Instant Deployment with git

One of the nicest things in git is that you can actually deploy code to production (or just your test environment) w/o implementing a complicated CI solution.
Off course that using CI such as Jenkins is recommended when compilation is required (JAVA/C/C++/C#) or when TDD/unit tests are use (and you better use them).
Yet, when you just need to deploy, git can be a great service for you.

Note: please note that you must an ssh access from the local machine (not always feasble).

How is done?
Actually it is very simple (and a complete explenation can be found at stackoverflow and toroid):

Step #1: Setup a repository in the development environment and commit a first file
> git init

Step #2: Setup an environment at the web server
> mkdir /path/to/dir/website.git && cd /path/to/dir/website.git
> git init --bare

Step #3: Enable a post receive hook at the web server
> mkdir /var/www/www.mydomain.com
> cat > hooks/post-receive
GIT_WORK_TREE=/var/www/www.mydomain.com git checkout -f
> chmod +x hooks/post-receive

Step #4: Create a trigger at the development environment (and why you need ssh access from the workstation).
> git remote add web ssh://www.mydomain.com/path/to/dir/website.git
> git push web +master:refs/heads/master

Step #5: Code, Commit and Push to production
> echo 'Rocking website!' > index.html
> git add index.html
> git commit -q -m "The index file was commited"
> git push web

Bottom Line
It is a simple task, but tricky if you don't have a direct access to the server (anyone said Jenkins?)

Keep Performing,
Moshe Kaplan

Feb 13, 2013

Tracing SQL Server Performance and Stability Issues

The following two undocumented stored procedures will do a miracle to your efforts to trace issues in SQL Server:

  1. EXEC sp_readerrorlog;
The first can be used to find failures, backup procedures and other goodies in the database log. The second can be used to trace heavy UPDATE, DELETE and INSERT transactions in the transaction log of a specific database.

Keep Performing,

Feb 11, 2013

mongoDB Configuration File Tuning

For those of us who are regular to MySQL, its configuration file (my.cnf) and the many options in it (some may say too many), mongoDB seems to be the simple.
With only few dozens of parameters in the configuration file (mongo.conf) and a dozen that are actually related to performance tuning, it may be a relatively short task to tune a mongoDB configuration file. Probably some of us will pay for that in production...

NOTE: this post does not refer the Sharding configuration.

What Can be Done?

Number of Connections
Like many other products (Apache httpd, MySQL...) the number of user connections can affect performance. mongoDB supports that using maxConns = N. Numbers can reach 20,000, but you should adjust it to your own server resources.

Write to Disk
Disk writing is usually a bottleneck in database systems. Therefore, wrtie to disk frequency and initial storage allocation can highly efhttp://stackoverflow.com/questions/8331099/what-is-the-javascript-engine-that-runs-mongodb-shellfect your system performance. Yet notice that delaying disk writing can effect your system recovery (many of you probably familiar with it from MySQL).
You should notice the following two options:
  1. Delay journal (database log) write to disk using journalCommitInterval = 300. This parameter supports intervals between 2ms (slowest but safest for recovery) and 300ms (fastest but prone to recovery options). The default os 100ms, but you may increase it to 300ms to save resources.
  2. Preallicate space at mongoDB startup by keeping noprealloc = false.
Disable Services
mongoDB provides many supporting services. Disabling some of them (if you do not use them), may help you save some CPU cycles:
  1. BSON validation using objcheck = false.
  2. HTTP Interface using nohttpinterface = true. The mongoDB HTTP interface exposes the database statistics and enables simple REST queries through port 28017.
  3. Scripting Engine using noscripting = true. mongoDB is using SpiderMonkey JavaScript scripting engine to enable interactive shell. Somehow, I have a feeling that you are not going to disable it.
  4. REST service using rest = false. See in the HTTP interface.
  5. Profiling service (inc. slow queries logging) using profile = 0.
Bottom Line
mongoDB is a simple, yet very effective tool to solve many business needs. Doing some tuning will help you avoid issues during peak times.

Keep Performing,

Feb 7, 2013

Jenkins? Tomcat? Running Code w/ Permissions? This script will probably help you!

If you need to run some "SUDO" commands from Jenkins, you will probably need to first 1) Add jenkins user to SUDO and 2) Avoid passwords.

The following code will do it like a miracle:

echo 'Providing SUDO script permissions to jenkins'
if ! grep -q 'jenkins' '/etc/sudoers'
        echo 'jenkins  ALL= NOPASSWD: ALL' >> /etc/sudoers
        echo 'Defaults:jenkins    !requiretty' >> /etc/sudoers
        echo 'Completed Successfully'
        echo 'Already Exists'

Keep Performing,


Intense Debate Comments

Ratings and Recommendations