Author: 芳草苑主

  • Download Magento via ssh

    wget http://www.magentocommerce.com/downloads/assets/1.3.2.3/magento-1.3.2.3.tar.gz

    If you download Magento from the download page, you see this link http://www.magentocommerce.com/getmagento/1.3.2.3/magento-1.3.2.3.tar.gz. But you can not use wget http://www.magentocommerce.com/getmagento/1.3.2.3/magento-1.3.2.3.tar.gz without specifying referrer. Some technique of anti hot link is implemented there.

  • Check if the port is in use

    netstat -nap | grep 8080

  • Do not give customers too many choices

    跟各种各样的顾客打交道,自我感觉我还是有较高的“customer oriented”意识,我一直认为这有利于达成交易。

    直到有一天,一个供应商突然通知我,某个第二天交货、双面印刷的订单他只印了一面,由于生产环境改变,他无法印另一面。我只有接受既成的事实,一方面安排运输,一方面想去通知客户这个坏消息。退客户一点钱倒是小事,当时我脑袋只想着事先告警好过客户收货以后发现该印两面的只印了一面。

    但老板阻止了我通知客户。他认为在客户什么都没有看到的情况下,如果是挑剔的客户,得知这个坏消息可能会在电话里脱口说,“我不要了”;而客户在收货以后十有八九会象我一样接受既成的事实,毕竟产品质量没有问题。

    我觉得我光想着给客户最好的服务,忽略了一些客服技巧。老板到底是老板,学习——

  • mysql_update

    When using phpmyadmin, after select a database, then click on Privileges, you might run into a error saying

    Unknown column ‘Event_priv’ in ‘field list’

    The error will go after you run

    mysql_upgrade

    in command line.

    I feel mysql query speed is improved after running “mysql_update”.

  • Connection speed of sourceforge

    Connection speed of the Godaddy server is generally slower than the 1&1 server. It was test proven from Europe and China. However, when connecting to downloads.sourceforge.net, Godaddy is faster.

    The Godaddy server automatically chooses the mirror site softlayer.dl.sourceforge.net, and the average speed is 8.55M/s. The 1&1 server chooses dfn.dl.sourceforge.net, and the speed is 70K/s. When I force the 1&1 server to download from softlayer.dl.sourceforge.net, the speed does not improve. It is slower even than I download from my PC via ADSL.

    I do not know why there is such a big difference in connection speed from different locations.

  • Gracefully restart Nginx

    Follow these 3 steps to gracefully stop and start Nginx without losing any queries. It works like a charm.

    1. Test new configuration is correct
      nginx -t
    2. Find the Pid
      ps -ef | grep "nginx: master process" | grep -v "grep" | awk -F ' ' '{print $2}'
    3. And kill it. Meanwhile, new configuration is already effective.
      kill -HUP ????
      (replace ???? with the Pid given in step 2)
  • Use Inkscape to open .ai and .cdr files

    Occasionally I need to open .ai (Adobe Illustrator) and .cdr (Coreldraw) files on Fedora, and I found Inkscape is good enough for me. I won’t edit these files so I don’t know Inkscape full capacity.

  • Speed bottleneck of the web server

    非常典型的多层架构:
    第一层 Nginx
    第二层 php fastcgi
    第三层 memcached
    第四层 MySql

    Apache 有个 mod_php,相当于合并了第一层和第二层,Nginx 没有 module for php,这不是什么问题,分层更利于扩展。第三层的加入完全是为了减轻数据库压力,提高性能。目前第2,3,4层之间的优化差不多到极限了(或者说到我能力的极限了),但第1,2层之间尚有潜力可挖。

    not_in_use.php 和 not_in_use.html 都是一个静态文件,没有数据库操作。但 php 文件必须由 Nginx 经由 php fastcgi (使用 unix socket)产生,html 则由 Nginx 直接访问文件系统,就单因素分析,php fastcgi 是普通文件系统速度的34%,所以要想办法绕开 php fastcgi。以下测试在数据中心主机上直接运行 ApacheBench。

    测试一:
    $ ab -kc 100 -n 500 http://magento/not_in_use.php
    This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
    Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
    Copyright 2006 The Apache Software Foundation, http://www.apache.org/

    Benchmarking magento (be patient)
    Completed 100 requests
    Completed 200 requests
    Completed 300 requests
    Completed 400 requests
    Finished 500 requests

    Server Software: nginx/0.6.36
    Server Hostname: magento
    Server Port: 80

    Document Path: /not_in_use.php
    Document Length: 7686 bytes

    Concurrency Level: 100
    Time taken for tests: 0.336355 seconds
    Complete requests: 500
    Failed requests: 0
    Write errors: 0
    Keep-Alive requests: 0
    Total transferred: 4089329 bytes
    HTML transferred: 4004406 bytes
    Requests per second: 1486.52 [#/sec] (mean)
    Time per request: 67.271 [ms] (mean)
    Time per request: 0.673 [ms] (mean, across all concurrent requests)
    Transfer rate: 11871.39 [Kbytes/sec] received

    Connection Times (ms)
    min mean[+/-sd] median max
    Connect: 0 11 17.8 3 58
    Processing: 13 49 17.9 50 94
    Waiting: 3 45 18.8 46 88
    Total: 25 60 14.2 61 94

    Percentage of the requests served within a certain time (ms)
    50% 61
    66% 70
    75% 72
    80% 74
    90% 79
    95% 80
    98% 84
    99% 86
    100% 94 (longest request)

    =======================================================
    测试二:
    $ ab -kc 100 -n 500 http://magento/not_in_use.html
    This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
    Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
    Copyright 2006 The Apache Software Foundation, http://www.apache.org/

    Benchmarking magento (be patient)
    Completed 100 requests
    Completed 200 requests
    Completed 300 requests
    Completed 400 requests
    Finished 500 requests

    Server Software: nginx/0.6.36
    Server Hostname: magento
    Server Port: 80

    Document Path: /not_in_use.html
    Document Length: 7686 bytes

    Concurrency Level: 100
    Time taken for tests: 0.115725 seconds
    Complete requests: 500
    Failed requests: 0
    Write errors: 0
    Keep-Alive requests: 500
    Total transferred: 3959000 bytes
    HTML transferred: 3843000 bytes
    Requests per second: 4320.59 [#/sec] (mean)
    Time per request: 23.145 [ms] (mean)
    Time per request: 0.231 [ms] (mean, across all concurrent requests)
    Transfer rate: 33406.78 [Kbytes/sec] received

    Connection Times (ms)
    min mean[+/-sd] median max
    Connect: 0 3 7.3 0 22
    Processing: 7 17 4.1 18 23
    Waiting: 7 16 4.0 17 23
    Total: 7 20 9.9 18 41

    Percentage of the requests served within a certain time (ms)
    50% 18
    66% 20
    75% 22
    80% 37
    90% 39
    95% 40
    98% 41
    99% 41
    100% 41 (longest request)

  • Fedora update made my system unbootable

    今天 Fedora 的一个更新后提示我 logout and relogin,结果我 logout 后死机。重启,进度条到100%后还是死机。

    幸好我注意到这个更新是关于 ntfs 的,马上把 /etc/fstab 里我添加的几个条目注释掉,系统又可以启动了。我再细察了/etc/fstab,关于 cifs 的加载,原先写得不是很规范,缺少 sec=none 参数,造成 Fedora 更新后不能启动。

  • Run opentaps as a service

    为了让 Opentaps 在系统启动后自动启动,我在 /etc/rc.d/rc.local 里添了一行

    /path/to/opentaps/startofbiz.sh

    在 Opentaps 1.0.4 版之前用这个方法启动 Opentaps 没发现大的问题,但 1.0.4 版运行 startofbiz.sh 的当前目录必须为 opentaps 的目录,不能再用上述办法启用 Opentaps。再说上述办法并不是正统的以 service 运行 Opentaps,所以我又重新寻找一个能让 Opentaps 自启动的办法。其实也很简单:

    1. 适当编辑 rc.ofbiz 的参数 (rc.ofbiz 似乎是在 DOS 下写就的,我用了一次 dos2unix 才让它运行起来)
    2. cp /path/to/opentaps/rc.ofbiz /etc/init.d/ofbiz
    3. chmod 755 /etc/init.d/ofbiz
    4. chkconfig --add ofbiz
    5. chkconfig --level 235 ofbiz on
    6. service ofbiz start