Category: How-To

  • Scaling from 100 to 100000 concurrent users in a day?

    Well, it looks pretty bad right now. A vendor just ceded control for web application architecture. Initial tests say that the site won’t do no more 100 users concurrently.

    Who the hell makes a web app without a slave database and calls themselves website architects? Apparently these guys did.

    Please start following if you want to see if this web app can make it to launch.

  • App Identifier and Bundle Identifier Gotcha in iPhone Dev

    This is one of those things they don’t mention in the docs.

    When you create a provisioning profile for an iPhone app you get an app identifier. It looks like this:
    KED2IOCNA.com.codebelay.barceftw

    In order to get your iPhone app in development into your iPhone you got to have a bundle identifier. The docs that I’ve found so far tell you that your bundle identifier is the same as your app identifier. After struggling for close to 4 hours, I found out that your bundle identifier really is:
    com.codebelay.barceftw

    Just strip out the encrypted looking part and the dot (.) before com and you’re set.

  • Advice for Middle Management

    Your team will sabotage your career worse than any other nemesis at work, if you let them.

    Here’s what you need to know to protect yourself and your company from sabotage:

    Who’s popular? Yeah, I know. It sounds like highschool, but like then it’s still in important and socially real factor that’s now kept track of on social media sites.

    What is your team’s weakness as perceived by those outside? By the team itself? A good manager can appease the two.

    Whose skills are the most respected? Yup you have to get along with this douchebag, if she or he is one. Just create enough space between the two of you.

    Any others?

  • How to Load Balance and Auto Scale with Amazon’s EC2

    This blog post is a quick introduction to load balancing and auto scaling on with Amazon’s EC2.

    I was kinda amazed about how easy it was.

    Prelims: Download the load balancer API software, auto scaling software, and cloud watch software. You can get all three at a download page on Amazon.

    Let’s load balancer two servers.

    elb-create-lb lb-example --headers \
    --listener "lb-port=80,instance-port=80,protocol=http" \
    --availability-zones us-east-1a

    The above creates a load balancer called “lb-example,” and will load balance traffic on port 80, i.e. the web pages that you serve.

    To attach specific servers to the load balancer you just type:

    elb-register-instances-with-lb lb-example --headers \
    --instances i-example,i-example2

    where i-example and i-example2 are the instance id’s of the servers you want added to the load balancer.

    You’ll also want to monitor the health of the load balanced servers, so please add a health check:

    elb-configure-healthcheck lb-example --headers \
    --target "HTTP:80/index.html" --interval 30 --timeout 3 \
    --unhealthy-threshold 2 --healthy-threshold 2

    Now let’s set up autoscaling:

    as-create-launch-config example3autoscale --image-id ami-mydefaultami \
    --instance-type m1.small
    as-create-auto-scaling-group example3autoscalegroup  \
    --launch-configuration example3autoscale \
    --availability-zones us-east-1a \
    --min-size 2 --max-size 20 \
    --load-balancers lb-example
    as-create-or-update-trigger example3trigger \
    --auto-scaling-group example3autoscalegroup --namespace "AWS/EC2" \
    --measure CPUUtlization --statistic Average \
    --dimensions "AutoScalingGroupName=example3autoscalegroup" \
    --period 60 --lower-threshold 20 --upper-threshold 40 \
    --lower-breach-increment=-1 --upper-breach-increment 1 \
    --breach-duration 120

    With the 3 commands above I’ve created an auto-scaling scenario where a new server is spawned and added to the load balancer every two minutes if the CPU Utilization is above 20% for more than 1 minute.

    Ideally you want to set –lower-threshold to something high like 70 and –upper-threshold to 90, but I set both to 20 and 40 respectively just to be able to test.

    I tested using siege.

    Caveats: the auto-termination part is buggy, or simply didn’t work. As the load went down, the number of the server on-line remained the same. Anybody have thoughts on this?

    What does auto-scaling and load balancing in the cloud mean? Well, the total cost of ownership for scalable, enterprise infrastructure just went down by lots. It also means that IT departments can just hire a cloud expert and deploy solutions from a single laptop instead of having to figure out the cost for hardware load balancers and physical servers.

    The age of Just-In-Time IT just got ushered in with auto-scaling and load balancing in the cloud.

  • Git: How to Cherry Pick Commits and Package them Under a Tag

    I’ve pretty much come to rely on git to pull me out of any bad jams in the chaotic environment I work in.

    One thing I’ve had to learn to do is cherry pick commits and package them under a tag in git.

    Here’s how to do it if you were working with my newLISP project called Sitebeagle:

    fork sitebeagle on this page

    cd sitebeagle

    git fetch –tags

    git checkout 8f5bb33a771f7811d21b8c96cec67c28818de076

    git checkout -b sample_cherry_pick

    git cherry-pick 22aab7

    git cherry-pick b1334775

    git diff sample_cherry_pick..master

    git tag leaving_out_one_commit

    git push origin –tags

    At this point, you should have a tagged branch that doesn’t have the commit with the change to the “2nd file.” The diff should look exactly like this:

    diff –git a/test.lsp b/test.lsp
    index 9cf1667..158b625 100755
    — a/test.lsp
    +++ b/test.lsp
    @@ -1,6 +1,7 @@
    #!/usr/bin/newlisp

    ; test tag test_a
    +; cherry pick test 2

    (load “sitebeagle.lsp”)
    (load “twitter.lsp”);

  • Overcoming File Encoding Issues

    Ever see characters any of these characters:

    1) ^M

    2) <feff>

    3) A black diamond with a white question mark in it.

    4) What<92>s going on?

    ???

    Does your version control system tell everything has changed when it doesn’t?

    Does your web app break because one of the above characters?

    If you answered yes to any of these questions, you are not alone!

    If you’ve dealt with this and figured out it please definitely shared your findings in the comments below.

    I believe it is *the* number one issue in working in a hybrid environment, e.g. with Windows, Linux, and OS X.

    In the next blog posts, I’ll talk about how I’ve struggled with these issues with other developers.

  • Setting Up a newLISP Webserver

    How fast can you get on the web? With newLISP it’s about as fast as typing:

    newlisp -http -d 8080 -w /usr/home/www/httpdocs &

    How fast can you create a backdoor with newLISP?

    newlisp -p 1234 &

    If you telnet into port 1234 in localhost, you’ll see something that looks like this:

    Trying 127.0.0.1…
    Connected to localhost.
    Escape character is ‘^]’.
    newLISP v.10.0.0 on OSX IPv4 UTF-8.

    >

    This opens up a lot of possibilities for distributed computing.

    For example, you can set up a newLISP server that’s ready to respond to a newLISP client with this command:

    newlisp -c -d 1234

    Your newLISP client can have code that sends a computing problem to be solved to the server:

    (net-eval “localhost” 1234 “(+ 3 4)” 1000)

    Or let’s say you had a farm of newLISP servers:

    #!/usr/bin/newlisp

    (set ‘result (net-eval ‘(
    (“192.168.1.100” 4711 {(+ 3 4)})
    (“192.168.1.101” 4711 {(+ 5 6)})
    (“192.168.1.102” 4711 {(+ 7 8)})
    (“192.168.1.103” 4711 {(+ 9 10)})
    (“192.168.1.104” 4711 {(+ 11 12)})
    ) 1000))

    (println “result: ” result)

    (exit)

    If the above example reminds you of Gearman, you get +12 points.

  • The Infamous Zed Shaw Declares ACL Is Dead

    If you work with ACL, this may be the most important video you watch ever. Zed shows how ACL is not Turing complete, which explains all the problems you’ve been having with control lists.


    Zed Shaw – The ACL is Dead from CUSEC on Vimeo.

  • Setting Up An EC2 LAMP Server

    Pre-requisites:

    Now we’re ready to build an EC2 LAMP Server.

    cd .ec2

    You’ll find that a lot of ec2 stuff happens in the .ec2 directory.

    To list the possible servers that you can set up run:

    ec2-describe-images -a

    I ran

    ec2-describe-images -a | wc -l

    and got 1477 possible servers. Some are Windows.

    Let’s say we see this listing:

    IMAGE ami-1539dc7c level22-ec2-images/ubuntu-8.04-hardy-20080205a.manifest.xml

    If we want to start up the ubuntu server listed above we just type:

    ec2-run-instances ami-5647a33f -k ec2-keypair

    And then we run this command:

    ec2-describe-instances

    We should see either “pending” or the actual instance running with its FQDN listed in the 4th column. An example FQDN is this:

    ec2-173-33-159-95.compute-1.amazonaws.com

    And if we go to:
    http://ec2-173-33-159-95.compute-1.amazonaws.com/

    we should see a webserver.

    And if we ssh:

    ssh -i ec2-keypair ec2-173-33-159-95.compute-1.amazonaws.com

    we’ll get the root prompt:
    #~

    That’s basically it. Now you can go in and mess around with server settings.

    In the next blog post, we’ll look at how to save your custom server settings and set up using S3.

  • Installing fcgi on IIS 6.0 with PHP 5.2.8

    Choose fcgi iis
    Choose IIS FastCGI
    Be sure to install extensions needed for WordPress
    Be sure to install extensions needed for WordPress

    Select these extensions:
    GD2
    Gettext
    Multi-Byte String
    Mimetypec
    MySQL
    MySQLi
    PDO/MySQL
    SQLite (in case MySQL fails)
    XML-RPC (WordPress needs this)

    Be sure to install Pear and the PHP Manual, too.

    Next step: Install FastCGI with the installer.

    For more info check out this page

    Also check out info how to install FastCGI on IIS 6.0.

    Install eAccelerator.

    My php.ini is below:

    [PHP]
    cgi.force_redirect=0
    extension_dir=”C:\Program Files\PHP\ext”
    [PHP_GD2]
    extension=php_gd2.dll
    [PHP_GETTEXT]
    extension=php_gettext.dll
    [PHP_MBSTRING]
    extension=php_mbstring.dll
    [PHP_MIME_MAGIC]
    extension=php_mime_magic.dll
    [PHP_MYSQL]
    extension=php_mysql.dll
    [PHP_MYSQLI]
    extension=php_mysqli.dll
    [PHP_PDO]
    extension=php_pdo.dll
    [PHP_PDO_MYSQL]
    extension=php_pdo_mysql.dll
    [PHP_SQLITE]
    extension=php_sqlite.dll
    [PHP_XMLRPC]
    extension=php_xmlrpc.dll

    ;eAccelerator
    extension=”eAccelerator.dll”
    eaccelerator.shm_size=”150″
    eaccelerator.cache_dir=”C:\cache”
    eaccelerator.enable=”1″
    eaccelerator.optimizer=”1″
    eaccelerator.check_mtime=”1″
    eaccelerator.debug=”0″
    eaccelerator.filter=””
    eaccelerator.shm_max=”0″
    eaccelerator.shm_ttl=”3600″
    eaccelerator.shm_prune_period=”1800″
    eaccelerator.shm_only=”1″
    eaccelerator.compress=”0″
    eaccelerator.compress_level=”9″
    eaccelerator.keys = “shm_only”
    eaccelerator.sessions = “shm_only”
    eaccelerator.content = “shm_only”

    My fcgiext.ini in %WINDOWS%/system32/inetsrv is below:

    [Types]
    php=C:\PROGRA~1\PHP\php-cgi.exe

    [C:\PROGRA~1\PHP\php-cgi.exe]
    QueueLength=999
    MaxInstances=20
    InstanceMaxRequests=500
    IdleTimeout=200
    RequestTimeout=60

    The performance you get on a 2GhZ processor with 1GiB of RAM is decent:

    Transactions:                     662 hits
    Availability:                 100.00 %
    Elapsed time:                 123.15 secs
    Data transferred:              21.96 MB
    Response time:                  8.29 secs
    Transaction rate:               5.38 trans/sec
    Throughput:                     0.18 MB/sec
    Concurrency:                   44.55
    Successful transactions:         662
    Failed transactions:               0
    Longest transaction:           13.25
    Shortest transaction:           4.23
    

    5.38 transactions per second is 464832 hits per day.