DynamoDB for PHP Session Storage            25 April 2012                                     Andreas Chatzakis           ...
Sessions in the cloudSticky sessions?Memcache?MySQL?Redis?Enter DynamoDB:Highly available – Consistently performingPersist...
Create a user            3
Create a table             4
Give Permissions{   "Statement": [     { "Sid": "Stmt1335183103764",       "Action": [         "dynamodb:BatchGetItem",   ...
Install & Configure SDKInstall the latest version of the SDK on your web serverimage - http://aws.amazon.com/sdkforphp/ Up...
Instantiaterequire_once /path-to/AWSSDKforPHP/sdk.class.php;// Instantiate the Amazon DynamoDB client.$dynamodb = new Amaz...
Update php.inisession.save_handler = userauto_prepend_file = /path-to/dynamosessions.php Restart web server Test Snapshot ...
ConsiderationsEstimate read/write throughput requirements Validate post go liveDoes your application need locking? By defa...
Upcoming SlideShare
Loading in...5
×

DynamoDB for PHP sessions

5,642

Published on

Step by step how-to for setting up amazon's dynamoDB as backend for storing PHP sessions. Presented at Greece's AWS Usergroup meetup.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
5,642
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "DynamoDB for PHP sessions"

  1. 1. DynamoDB for PHP Session Storage 25 April 2012 Andreas Chatzakis @achatzakis on twitter AWSUG Greece Not affiliated with, sponsored or endorsed by AWS
  2. 2. Sessions in the cloudSticky sessions?Memcache?MySQL?Redis?Enter DynamoDB:Highly available – Consistently performingPersistentAWS SDK now includes drop in PHP sessionhandler replacement 2
  3. 3. Create a user 3
  4. 4. Create a table 4
  5. 5. Give Permissions{ "Statement": [ { "Sid": "Stmt1335183103764", "Action": [ "dynamodb:BatchGetItem", "dynamodb:DeleteItem", "dynamodb:DescribeTable", "dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:Scan", "dynamodb:UpdateItem" ], "Effect": "Allow", "Resource": [ "arn:aws:dynamodb:us-east-1:846544612030:table/php-sessions-test"] } ] } 5
  6. 6. Install & Configure SDKInstall the latest version of the SDK on your web serverimage - http://aws.amazon.com/sdkforphp/ Update config.inc.php with the credentials of the user we created in step 1 the default-cache-config parameter (we went for apc, as it is already running on our instances.) any other parameters depending on your specific setup details (the file is well documented) 6
  7. 7. Instantiaterequire_once /path-to/AWSSDKforPHP/sdk.class.php;// Instantiate the Amazon DynamoDB client.$dynamodb = new AmazonDynamoDB();$dynamodb->set_hostname("https://dynamodb.us-east-1.amazonaws.com");// Register the DynamoDB Session Handler.$handler = $dynamodb->register_session_handler(array( table_name => php-sessions-test, hash_key => id, session_lifetime => 0, consistent_reads => true, session_locking => false, max_lock_wait_time => 15, min_lock_retry_utime => 5000, max_lock_retry_utime => 50000,)); 7
  8. 8. Update php.inisession.save_handler = userauto_prepend_file = /path-to/dynamosessions.php Restart web server Test Snapshot fresh AMI 8
  9. 9. ConsiderationsEstimate read/write throughput requirements Validate post go liveDoes your application need locking? By defaultphp implements pessimistic locking. The class provided by AWS supports it Configure it to FALSE if you dont need it (this will decrease costs and increase performance). Thorough testing would be required to validate your selection. 9

×