Using PHP and M y SQL to Build Applications with Windows Azure
description
Transcript of Using PHP and M y SQL to Build Applications with Windows Azure
Using PHP and MySQL to Build Applications with Windows AzureMohit Srivastava & Tushar Shanbhag
SVC51
Agenda> Interoperability
>PHP & Eclipse >memcached>MySQL
> Customer Showcases
> Technology Drilldowns
Windows Azure + Interoperability
> Windows Azure Capabilities> On-Demand Computational Resources> Storage at Massive Scale> Automated Service Management> Goal: Give You More Time to Write
Code
> …with Skills of your Choice> Languages> Tools> Application Components
PHP
Interoperability in this Session> Popular Technologies, Used by
> Sites: Facebook, Wikipedia> Apps: WordPress, MediaWiki
> …with Windows Azure Benefits> Get Started Easily: PHP/Eclipse Developer Experience> Maintain and Scale: Leverage Platform Primitives
> Cloud Storage> Inter-role Communication + Endpoint Discovery> …
PHP Web Development LanguageEclipse Development EnvironmentMySQL Relational Databasememcached
Distributed Memory Cache
Agenda> Interoperability
>PHP & Eclipse>memcached>MySQL
> Customer Showcases
> Technology Drilldowns
Using PHP with Windows Azure> Running PHP Code in Windows Azure
> Eclipse Tooling> Build, Test, Deploy PHP Projects> Create New or Use Existing PHP Projects
> Scaling PHP Apps
> Using Cloud Storage from PHP> Using Windows Azure Storage> Using SQL Azure
Running PHP in Windows Azure> How to Do It
> Host in Web role (like .NET)> Supply PHP runtime> Point to runtime via FastCGI
configuration in> Web.config> Web.roleConfig
> Eclipse Tooling @ http://windowsazure4e.org does the above for you
PHP Web Role
Instance 2
VIP
Load
Ba
lanc
er PHP Web Role
Instance 1
Using PHP & Eclipse with Windows Azure
Demo
PHP + Cloud Storage
PHPWeb Role
VIP
Load
Ba
lanc
er
Windows Azure Storage
SQL Azure
PHP App
Windows Azure Platform
On-Premis
es
PHP with Windows Azure Storage> Windows Azure SDK for PHP @
http://phpazure.codeplex.com
> PHP programming model for Windows Azure Storage
> Features > PHP classes for Blobs, Tables & Queues> Store PHP sessions in Table Storage
PHP with SQL Azure> SQL Server Driver for PHP @
http://sqlsrvphp.codeplex.com/
> Supports PHP access to SQL Azure
> Features> Choose between SQL Server and SQL
Azure by changing connection string> Use from on-premises or in Windows Azure
PHP + Cloud Storage
Windows Azure Storage & SQL Azure
Demo
Agenda> Interoperability
>PHP & Eclipse>memcached>MySQL
> Customer Showcases
> Technology Drilldowns
Customer Showcase: Adslot> Highly scalable auction service that enables
advertisers to realize significant discounts by bidding on combinations of keywords at a time
> Windows Azure Adoption Drivers> Computation-Heavy> Real-time Performance> Interop between .NET and non-.NET technologies
> ASP.NET> memcached, a distributed object cache
Customer Showcase: Adslot
Web Role
ComputationWorker Role
> memcached for ASP.NET MVC Models & Intermediate Computation Results
> Dynamically Scale memcached Tier
VIP
Load
Ba
lanc
er
memcached Worker Role
memcached Client Codeprivate MemcachedClient InitializeClient() { var client = new MemcachedClient(); foreach (var inst in RoleEnvironment.Roles["memcached"].Instances) { client.Add(inst.Id, inst.InstanceEndpoints["query"]); } return client; } public void Go() { // Initialize the memcached client var client = InitializeClient(); // Reinitialize the client when there is a topology change RoleEnvironment.Changed += (sender, args) => { if (args.Changes.Any(chg => chg is RoleEnvironmentTopologyChange)) { client = InitializeClient(); } }; // Use the client var value = client.Get("mykey"); }
memcached Solution Accelerator> Delivered by Infosys
> memcached Client (Web Role)> Uses Enyim client library> Supports “consistent” hashing, to
minimize cache invalidation when nodes are added or removed
> memcached Server (Worker Role)
Agenda> Interoperability
>PHP & Eclipse>memcached>MySQL
> Customer Showcases
> Technology Drilldowns
MySQL: Simple Configuration
Web
Rol
e
VIP
Load Balancer
Wor
ker
Role
MySQL
MySQL in a Windows Azure Application> Running MySQL in a worker role
> Copy MySQL to the worker role sub-directory
> Copy to read-write local storage> Configure MySQL to listen on the right
port> Monitor MySQL health
> Consuming MySQL> Discover IP address and port> Normal access from then on> Handle topology changes
MySQL
Demo
Simple Configuration
VIP
Load Balancer
MySQL
Replication
VIP
Load Balancer
MySQL MySQLMySQLMS S
Windows Azure Drive with Hot Spare
VIP
Load Balancer
MySQL MySQL
Windows Azure Drive with Hot Spare
VIP
Load Balancer
MySQL MySQL
MySQL Solution Accelerator> Built by our partner, Infosys
> Master/slave configurations in a worker role> Leverage Windows Azure Drive> Master election and replication on startup> Failover and recovery> Scale up/down slaves> Periodic backups - full and incremental
> Available with source code
MySQL Solution Accelerator
Demo
Administering MySQL> Some users prefer a command-line> Instance Manager solution accelerator
> Built by our partner Infosys> Command-line access to worker role
instances> Server runs in each worker role instance> Client runs in a web roleWorke
r
Worker
Instance ManagerSolution Accelerator
Demo
Solution Accelerators> MySQL and Memcached
> Best-practice deployments> Leverage Windows Azure primitives:
> Windows Azure Drive> Windows Azure storage> Discovering IP addresses, other servers,
lifecycle> Dynamic Scaling, Failover, and Upgrades> Automation of application lifecycle
> Instance Manager for remote command
Agenda> Interoperability
>PHP & Eclipse>memcached>MySQL
> Customer Showcases
> Technology Drilldowns
Spotlight: MediaWiki > Powers Wikipedia> PHP-based, usually with MySQL and
Memcached> Used by many companies
> Internal knowledge management> Content management system (CMS)
> Windows Azure benefits> Support traffic spikes> Support unpredictable growth> Minimize possibility of data loss> Minimize downtime
Spotlight: MediaWiki> Technology Requirements
> Web server w/PHP support, MySQL for storage, memcached for caching query results
> What we’ve added : phpMyAdmin and Instance Manager
VIP
Inst
ance
M
anag
er
MCached_2
MCached_3
MCached_1
Med
iaw
iki
PhpM
yAdm
in MySQL Solution
Accelerator
Web Roles Worker Role
Wor
ker R
ole
Memcached Solution Accelerator
Load
Ba
lanc
er
MySQL 1
MySQL 2
Agenda> Interoperability
>PHP & Eclipse>memcached>MySQL
> Customer Showcases
> Technology Drilldowns
Customer Showcase: Glympse> Mobile consumer application that allows
people to share and view their location in real-time
> Windows Azure Adoption Drivers> Support spiky traffic> Automated service management> Geo-availability> Ease of development
Customer Showcase: Glympse> Technical Requirements
> MySQL backend for storing tour data, memcached for caching, php for displaying results to web
VIP
Load
Ba
lanc
er
FE_2
MCached_2
MCached_3
MCached_1
FE_1
FE_3
Web Role Worker Role
Wor
ker
RoleMyS
QL
Glympse
Demo
Benefits of Database as a ServiceSQL AzureDatabase as a Service> Lower TCO> Automatic High Availability
> Multiple servers with live copies of your data --- instant failover
> Automatic Fault-Tolerance> Automatic maintenance
> No downtime> Instantly expand/contract
databases to meet application needs
> Metered by database> Mission-critical SQL Server
foundation
MySQL Solution Accelerator> Compatibility w/ MySQL apps> Pre-configured clustering across
multiple compute instances> Database maintenance required> Metered by compute hour
Clear commitment to OSS support and application compatibility SQL Azure is our strategic investment for the Windows Azure
Platform
Takeaways> Powerful platform primitives> Support for PHP and Eclipse> Accelerators for MySQL and
Memcached
> In use in real-world applications
Call To Action> Windows Azure Monitoring, Logging, and
Management APIs – 11/18 (11:00 AM)
> Windows Azure Tables and Queues Deep Dive – 11/18 (3:00 PM)
> Windows Azure Blobs and Drives Deep Dive – 11/18 (4:30 PM)
> Automating the Application Lifecycle with Windows Azure – 11/19 (10:00 AM)
YOUR FEEDBACK IS IMPORTANT TO US! Please fill out session evaluation
forms online atMicrosoftPDC.com
Learn More On Channel 9> Expand your PDC experience through
Channel 9
> Explore videos, hands-on labs, sample code and demos through the new Channel 9 training courses
channel9.msdn.com/learnBuilt by Developers for Developers….
© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.