RightScale Tutorial

If you need help configuring aiCache Click Here:


For list of RightScale features and pricing model, check RightScale Overview
Download config template - it will help you to start quickly and have some changes vital for RightScale Template.

Basic setup

Creating security groups

Security groups are a firewall setting for Amazon EC2 servers.
Open Clouds > AWS US > Security Groups and click New.
Create group AiCache with any description you like and open ports 22 (SSH to login) and 80 (AiCache web).

Dns configuration

By default Amazon EC2 instances receive dynamic IP. To avoid IP change, purchase Elastic IP and associate it with aiCache DNS name.
Open Clouds > AWS US > Elastic IP and click New. Rename new Elastic IP ( on the screenshot) to AiCache.

Also setup A record for site in your DNS provider control panel.
I prefer to start with something like test.aicache.com, test aiCache on it, then switch A records for main site - aicache.com and www.aicache.com in this example.

Preparing aiCache config file

Download config template first. It provides sane defaults to start, but few variables listed below must be manually adjusted.

Changing website name:
hostname aicache.com             # MUST CHANGE to your hostname
cname    www.aicache.com         # Alternative name
cname    test.aicache.com        # For testing
wildcard amazonaws.com           # For quick testing with public amazon ec2 addresses
Hostname is an exact match and only one record allowed for website. Cname is also an exact match with many records allowed.
Wildcard is a mask - one above will match to public amazon addresses so you can test site quickly after start without DNS changes.

healthcheck /url HTTP 5 4     # Format: url match NN MM.
                              # Each NN seconds url of origin server will be checked for response type match, which must be received within MM seconds.

                              # In case of error - no response within MM or response data that doesn't match "match" - origin server temporarily disabled.

pattern \.php regexp 1m       # cache for 1 minute, use with caution
pattern .css simple 7d no_log # cache for a week, do not log in acces log file

Origin servers:
origin aicache.com 80         # Aicache server as testing origin, replace it with your server - preferably IP address.
                              # For EC2 or RS servers within same zone you have to use insternal IPs to avoid fees for extra traffic.
Rest of the settings can be found in aiCache Administrator Guide.

Uploading config to S3

aiCache template fetch settings from S3, so create one.
Open Clouds > AWS Global > S3 Browser. Click New Bucket and create bucket like <company_name>_config. Keep in mind that S3 bucket names must be unique across all users.
Upload updated config file.

If you going to use certificate and key for https, upload them to S3 bucket too.

Import aiCache template

Open Design > Server templates > View Library. Find aiCache template and import latest version.
You may also import aiCache Toolbox for connect\disconnect scripts for your origin templates.

Launching aiCache server

Go to deployuemt you want to use and click Add server.
Open Imported group and aiCache, add AiCache security group, select AiCache Elastic IP, check "associate IP at launch".

Import variables explanation:
AIC_CFG_BUCKET        - Config bucket name. Required.
AIC_CFG_FILE          - Config in S3. Required.
AIC_CERT_FILE         - Certificate file name in S3 bucket. Optional, set to ignore if not used.
AIC_KEY_FILE          - Key file name in S3 bucket. Optional, set to ignore if not used.
AWS_ACCESS_KEY_ID     - AWS access key from credentials.
AWS_SECRET_ACCESS_KEY - AWS secret key from credentials.
MON_PROCESSES         - Must be "aicache alert". Required for monitoring and alerts.
SYSLOG_SERVER         - Must be "syslog.rightscale.com". Required for monitoring.
SYS_TZINFO            - Timezone of the server.
Click Save and Launch and wait till server become operational.

Testing aiCache and switching to production

Open test url in the browser - e.g. http://ec2-50-16-141-77.compute-1.amazonaws.com/. If it shows output from origin server, aiCache works and you can change dns records for root and www.
Check Troubleshooting section below if something wrong.

Safely turning aiCache off

Restore old IPs on www and root A records. Do not terminate AiCache instance immidiately - wait for DNS records to refresh.
After DNS records expire, AiCache server can be terminated.

Advanced usage

Updating config file on the fly

Upload updated config file to S3, open Scripts tab of the aiCache server and find "AIC S3 Configure" script.
Run it, check status in audit entries.
This will update config from s3 and softly restart aicache (without breaking existing connections). However, keep in mind that it won't change external IP address of the main server and some other settings, so it can be used only on minor changes. For major updates simply clone aiCache server with all settings, launch it and update DNS records when it's ready.

Connecting RS origin server to aiCache using haproxy scripts.

For RS templates like "PHP App Server" or "Tomcat6 App Server", you can use their LB Haproxy scripts to interact with aiCache.
This meothod is not preffered, because RS scripts does not give access to aiCache specific features.
"LB app to HA proxy connect v3" - will be used to connect to aiCache template.
"LB app to HA proxy disconnect v2" - to disconnect.
To configure aitoscaling, add "connect" to the boot section (it's not there by defailt for some templates) and ensure that "disconnect" script will run during decomission.
Keep in mind that origin server addresses will survive during reboot, but not relaunch of the aiCache server.
If you created new aiCache or relaunched old, you have to add all origins again.
LB_APPLISTENER_NAME - all or www will add origin to all website sections of your config.
                      If you wish to update only one section, use hostname here, like aicache.com (exact match, cnames are ignored).
LB_HOSTNAME         - aiCache server to connect to or disconnect from. Can be multiple space-separated addresses.
LB_BACKEND_NAME     - Ignored
HEALTH_CHECK_URI    - Ignored. Check config section above for health settings.
Scripts above use port 8000. If you need another port, use custom aiCache scripts.

Connecting custom origin server to aiCache.

If you create your own template (or use clonned and modified one), you can utilize "AIC Connect" and "AIC Disconnect" from aiCache Toolbox. This is preffered method, since it provides aiCache-specific features.
"AIC Connect" - add to boot and operational sections of your template.
"AIC Disconnect" - add to operational and decomission sections.
LB_SECTION  - all or www will add origin to all website sections of your config.
              If you wish to update only one section, use hostname here, like aicache.com (exact match, cnames are ignored).
LB_HOSTNAME - aiCache server to connect to or disconnect from. Can be multiple space-separated addresses.
APP_TYPE    - http or https. Protocol aiCache will use to talk to origin. Note that aiCache can serve https with http origin.
APP_PORT    - port to use.

Alerts for high availability

Template config have RS alerts disabled, because they necessary only on high-availability system, and quite annoying on others.
To ensure that RS will send emails to you, open Design > Alert Escalations > View All
AiCache generates warning alerts only, so make sure you have "send_email" action for this level.

Also update following lines in config:
alert_req_sec_max  2500 # When set, an alert is generated when number of RPS exceeds this number
alert_req_sec_min    10 # When set, an alert is generated when number of RPS is less than this number
alert_bad_resp_sec    2 # When set, an alert is generated when total number of failed responses from origin servers exceeds this number
alert_os_rt         200 # When set, an alert is generated when origin server response time is more than this number (milliseconds)
                        # To disable any above alerts, just remove or comment corresponding line in config file
Run "AIC S3 Configure" and aiCache will generate alerts.


If aicache is not working...
* Check audit entries, especially AIC S3 Configure output.
* Start with config template and try to launch aiCache server with it.
* Use Pattern testing tool from Download Page to check patterns.
* SSH to aiCache server and run:
cd /usr/local/aicache
export LD_LIBRARY_PATH=/usr/local/lib
/usr/local/aicache/aicache -c rs -f /root/default.cfg
Check logs in /mnt/aicache
* And if nothing helps, you always have free 2 hours of support.

Subpages (1): Rightscale help
Support Group,
Jan 15, 2011, 6:23 AM