Running PHP on the Windows Azure Platform
Brian SwanPHP Developer Advocate
[email protected] @brian_swan
http://blogs.msdn.com/b/brian_swanhttp://blogs.msdn.com/b/silverlining
Lots I could talk about…
• Why is PHP 5.3 faster on Windows than previous versions of PHP?
• Version 3.0 (beta) of the SQL Server Driver for PHP is available.
• SQL Server ODBC driver for Linux is coming.
• Hadoop for Windows Server/Azure is coming.
But I’ll tour Windows Azure(by looking at auto-scaling)
Windows Azure Boot Camp WindowsAzureBootCamp.com
Windows Azure Platform Overview
ON-PREMISES LOB ApplicationsComposite applications
Developer ExperienceUse existing skills and tools.
Compute Storage Management Relational data Management Connectivity Access control
AppFabric
Packaged Software
Storage
Servers
Networking
O/S
Middleware
Virtualization
Data
Applications
Runtime
You
man
age
Infrastructure(as a Service)
Storage
Servers
Networking
O/S
Middleware
Virtualization
Data
Applications
Runtime
Managed by vendor
You
man
age
Platform(as a Service)
Managed by vendor
You
man
age
Storage
Servers
Networking
O/S
Middleware
Virtualization
Applications
Runtime
Data
Software(as a Service)
Managed by vendor
Storage
Servers
Networking
O/S
Middleware
Virtualization
Applications
Runtime
Data
What type of cloud is Windows Azure?
What are Web and Worker roles?
Web Role• External Facing • HTTP/HTTPS
Endpoint• Short lived calls(Think Web Server)
Worker Role• Internal Facing • TCP/HTTP Endpoint• Long running
processes(Think Service or
Deamon)There is also a VM Role • You configure and maintain the OS.• Lacks persistent state.
In general, think of a “role” as on OS template.
Instance Sizes and Costs
Size Cores CPU Speed Memory Cost/hour
Ex. Small Shared 1.0 GHz 768 MB $0.04
Small 1 1.6 GHz 1.75 GB $0.12
Medium 2 1.6 GHz 3.5 GB $0.24
Large 4 1.6 GHz 7 GB $0.48
Ex. Large 8 1.6 GHz 14 GB $0.96
What is Azure Storage?
Blobs: large, unstructured binary data (audio, video, etc.)
Tables: simply (and loosely) structured data (not relational)
Queues: serially accessed messages
Storage Costs $0.14 GB/month*
$0.01/10k transactions
* http://blogs.msdn.com/b/windowsazure/archive/2011/10/27/microsoft-lowers-storage-cost-for-blob-and-table-storage-in-windows-azure.aspx
Transfer Costs $0.15 GB outbound
Don’t forget
Azure Table StoragePartition Key
Row Key Timestamp DeliveryAddress OrderAmount
Kirk NC1701 10/24/2011 6:05:15 PM
6855 Kobayashi Maru Drive
$35,490.00
Kirk NC1701A 10/23/2011 6:09:10 PM
409 Tiberious Road
$98.99
Kirk NC1701B 10/24/2011 6:00:15 AM
1024 Priceline Ave
$4,523.99
Archer 31415 11/20/2010 8:05:15 AM
999 Sliders Blvd $5,780.99
Archer 1 10/04/2011 6:55:15 PM
1405 Suliban Road
$55.39
Archer 234 09/24/2011 6:05:15 AM
DS9, Level 29, Suite 782
$1.58
Bender 1 10/24/2010 7:05:15 PM
900 South Futurama Drive
$87,399.99
VIN
12345
KJUDH
Super Fast• Unique Partition Key
Very Fast• Partition Key + Row Key
Slower
• Only Partition Key• No Row Key
Slowest
• No Partition Key• No Row Key
Query Performance
Azure Blob Storage
BlobContainerAccount
mymedia
images
PIC01.JPG
videos
http://<account>.blob.core.windows.net/<container>/<blobname>
PIC02.JPG
VID01.AVI
Containers and Blobs• Containers
– Multiple containers per account– Create/destroy on the fly– One container can hold up to 100 TB* worth of blobs– Set access policies (private, public read, full public read)– Set metadata
• No search/query (i.e. no WHERE MetadataValue = ?)
• Blobs– A blob can be up to 1 TB in size– Set access policy– Set metadata
*100 TB is the size limit for an entire storage account
What is the Diagnostics Monitor?An Azure component (MonAgentHost.exe) that collects diagnostic data for application instances– Starts automatically by default– Must define a storage account connection string
How does it work (in a nutshell)?
Role Instance Starts Diagnostic Monitor Starts Monitor is configured
Imperatively at Start time Remotely any time
Monitor buffers data locally User can set a quota (FIFO)
User initiates transfer to storage Scheduled or On Demand
Role
Role Instance
Diagnostic Monitor
Local directory storage
Windows Azure Storage
Diagnostic Data SourcesData Source Default Destination
Trace Logs Enabled Table
Diagnostic Infrastructure Logs Enabled Table
IIS Logs Enabled Blob
Performance Counters Disabled Table
Windows Event Logs Disabled Table
IIS Failed Request Logs Disabled Blob
Crash Dumps Disabled Blob
Arbitrary Files Disabled Blob
What is the Management API?
• A REST API that allows you to manage services under an Azure subscription.– Examples include…
• Create/stop/start/delete a deployment• Move staging deployment to production• Increasing the number of instances• Initiate a rolling upgrade• Etc.• (almost anything you can do via the management portal)
• All API calls must be signed with an X509 certificate
Windows Azure SDK for PHP• http://phpazure.codeplex.com/
– Open Source project– Mostly platform independent (only the packaging tools have a Windows
dependency)
• Features – PHP classes for Windows Azure Blobs, Tables & Queues– Scaffolds for quick application deployment– Helper Classes for HTTP transport, AuthN/AuthZ, REST & Error Management – Manageability, Instrumentation & Logging support – Support for storing PHP sessions in Azure Table Storage – Management API client – Diagnostics client – Command line tools set for packaging, management , diagnostics, and deployment
DemoAuto-scaling a Windows Azure/PHP application
Windows Azure SDK for PHP + …
Code
• GolferMessageBoard code is on the TechNet Wiki: http://social.technet.microsoft.com/wiki/contents/articles/use-the-windows-azure-web-role-and-windows-azure-blob-service-with-php.aspx
• Auto-scaling code is on GitHub: https://github.com/brian-swan/PHP-Auto-Scaler – Read about it here: http://
blogs.msdn.com/b/silverlining/archive/2011/10/05/an-auto-scaling-module-for-php-applications-in-windows-azure.aspx
Other Resources• http://blogs.msdn.com/b/silverlining
– A PHP on Windows Azure Learning Plan• http://blogs.msdn.com/b/brian_swan• https://github.com/brian-swan• http://azurephp.interoperabilitybridges.com/• Why is PHP 5.3 faster on Windows than previous versions of P
HP?
• Version 3.0 (beta) of the SQL Server Driver for PHP is available.• SQL Server ODBC driver for Linux is coming.• Hadoop for Windows Server/Azure is coming.
Try It Out
http://www.microsoft.com/windowsazure/free-trial/
Q & A?
Top Related