62
Just another Wordpress weblog, but more cloudy WUX211 M aarten Balliauw @ maartenballiauw

Just another Wordpress weblog, but more cloudy

Embed Size (px)

DESCRIPTION

While working together with Microsoft on the Windows Azure SDK for PHP, we found that we needed an popular example application hosted on Microsoft’s Windows Azure. Wordpress was an obvious choice, but not an obvious task. Learn more about Windows Azure, the PHP SDK that we developed, SQL Azure and about the problems we faced porting an existing PHP application to Windows Azure.

Citation preview

Page 1: Just another Wordpress weblog, but more cloudy

Just another Wordpress weblog,but more cloudy

WUX211

Maarten Balliauw

@maartenballiauw

Page 2: Just another Wordpress weblog, but more cloudy

Who am I?• Maarten Balliauw• Antwerp, Belgium• www.realdolmen.com • Focus on web

• ASP.NET, ASP.NET MVC, PHP, Azure, VSTS, …• MVP ASP.NET

• Interested in interoperability• PHPExcel, PHPLinq, Windows Azure SDK for PHP, ...

• http://blog.maartenballiauw.be • http://twitter.com/maartenballiauw

Page 3: Just another Wordpress weblog, but more cloudy
Page 4: Just another Wordpress weblog, but more cloudy

Agenda

• Cloud computing?• Windows Azure?• Application architecture• Using PHP with Windows Azure• Wordpress• Resources• Q&A

Page 5: Just another Wordpress weblog, but more cloudy

What’s in the cloud?

Cloud Computing

Page 6: Just another Wordpress weblog, but more cloudy

What is Cloud Computing ?• What is cloud computing ?

• Offering infrastructure, platform and software as a service over the internet to a global market.

• Move on-premises management of non functional IT assets to a provider.

• Difference from traditional hostings• Sold on demand “pay as you grow”• Elastic scalability• Service is fully managed by the provider• End user centric (IW or developer)• Strong focus on integration (cloud-cloud or cloud-on-premises)

Page 7: Just another Wordpress weblog, but more cloudy

Definition of cloud (NIST)

• On-demand self service• Standardized access• Location independant resource

pooling• Rapid elasticity• Pay per use

Page 8: Just another Wordpress weblog, but more cloudy

IT as a ServicePrivate

(On-Premise)Infrastructure(as a Service)

Platform(as a Service)

Storage

Server HW

Networking

Servers

Databases

Virtualization

Runtimes

Applications

Security & Integration

Storage

Server HW

Networking

Servers

Databases

Virtualization

Runtimes

Applications

Security & Integration

Storage

Server HW

Networking

Servers

Databases

Virtualization

Runtimes

Applications

Security & Integration

You m

anage

Managed b

y v

endor

Managed b

y v

endor

You m

anage

You m

anage

Page 9: Just another Wordpress weblog, but more cloudy

Microsoft’s cloud

Windows Azure

Page 10: Just another Wordpress weblog, but more cloudy

The Windows Azure Platform• Windows Azure• SQL Azure• Windows Azure platform

AppFabric• Microsoft Codename “Dallas”• Microsoft Codename “Sydney”

Page 11: Just another Wordpress weblog, but more cloudy

Windows Azure

• Flexible application hosting• Lights-out service management

• Provide code & service model, hit ENTER

• Storage at massive scale• Blobs, tables, queues

Compute StorageManagement

There’s an SDK for this: http://phpazure.codeplex.com

Page 12: Just another Wordpress weblog, but more cloudy

Windows Azure

Page 13: Just another Wordpress weblog, but more cloudy

Windows Azure Data Storage

Account

Queue

Blob

Tables

Drives

Page 14: Just another Wordpress weblog, but more cloudy

Storage options

• Blobs, tables, queues• Windows Azure Drive (a.k.a. XDrive)• Virtual NTFS volume that can be mounted• .vhd format• Use existing NTFS API’s• Easier migration• Stored on blob storage provides quick

mount/unmount in other VM

Page 15: Just another Wordpress weblog, but more cloudy

SQL Azure

• Relational database as a service• Highly available, automatically maintained

• Extension of the SQL Server Data Platform

Database

Reporting Business Analytics Data Sync

There’s a driver for this: http://sqlsrvphp.codeplex.com

Page 16: Just another Wordpress weblog, but more cloudy

SQL Azure

• Relational database, provided as a service• Highly symmetrical development and tooling

experience (use TDS protocol and T-SQL)• Highly scaled out, on commodity hardware• Built on the SQL Server technology

foundation• High availability, DB provisioning, and DB

management are provided by the service

Page 17: Just another Wordpress weblog, but more cloudy

Windows Azure AppFabric

• Secure connections between services• Across organizational boundaries

• Claims-based access control

ServiceBus

AccessControl

There’s an SDK for this: http://dotnetservicesphp.codeplex.com/

Page 18: Just another Wordpress weblog, but more cloudy

Service Bus Overview

Page 19: Just another Wordpress weblog, but more cloudy

Windows Azure AppFabric - Service Bus

• Securely connect applications• Over the internet• Across any network topology (= across firewalls!)• Across organizational boundaries

• Primary application patterns• Eventing:

• Notify applications and/or devices

• Service Remoting: • Securely project on-premises services out to the cloud

• Tunneling: • App-to-app communication with NAT/Firewall traversal

Page 20: Just another Wordpress weblog, but more cloudy

• PortBridge - http://bit.ly/bCDrUs• Bridge TCP over Service Bus

A fun usage scenario…

Page 21: Just another Wordpress weblog, but more cloudy

Microsoft Codename “Dallas”

• Content brokerage and discovery platform

• Available as a CTP

Microsoft Codename “Dallas”

Information Services

Page 22: Just another Wordpress weblog, but more cloudy

Microsoft Codename “Sydney” - Connectivity

WINDOWS AZURE PLATFORM

Data Service

Service Bus

Access Control Service

ENTERPRISE

Code Name “Project Sydney”

Page 23: Just another Wordpress weblog, but more cloudy
Page 24: Just another Wordpress weblog, but more cloudy
Page 25: Just another Wordpress weblog, but more cloudy

Developer tools

• Development• Use your favourite editor

• Local debugging• Windows with IIS 7.x• Visual Studio• Windows Azure tools for Eclipse

• Packaging• Windows Azure SDK

• Deployment• Any browser

Page 26: Just another Wordpress weblog, but more cloudy

Your typical cloud applicationApplication architecture

Page 27: Just another Wordpress weblog, but more cloudy

Typical Architecture on Azure

Windows Azure Storage (Blob, Table, Queue)

VI P

Web Role

Worker Role

Service Unavailable

Page 28: Just another Wordpress weblog, but more cloudy

Web + Worker Role Service Model

Windows Azure Storage (Blob, Table, Queue)

Worker RoleWeb

Role

VI P

Web Role

Worker Role

Worker Role

Worker Role

Worker RoleService Still Available

Page 29: Just another Wordpress weblog, but more cloudy

How about that?PHP & Windows Azure

Page 30: Just another Wordpress weblog, but more cloudy

• It’s all about…

• 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

Using PHP with Windows Azure

Page 31: Just another Wordpress weblog, but more cloudy

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 athttp://windowsazure4e.org does the above for you

PHP Web RoleInstance 2

VI P

Load

Bala

nce

r

PHP Web RoleInstance 1

Page 32: Just another Wordpress weblog, but more cloudy

PHP + Cloud Storage

PHPWeb Role

VI P

Load

Bala

nce

r

Windows Azure Storage

SQL Azure

PHP App

Windows Azure Platform

On-Premis

e

Page 33: Just another Wordpress weblog, but more cloudy

PHP with Windows Azure Storage• Windows Azure SDK for PHP at

http://phpazure.codeplex.com

• PHP programming model for Windows Azure Storage

• Features • PHP classes for Blobs, Tables & Queues• Store PHP sessions in Table Storage• File system wrapper for Blob Storage

Page 34: Just another Wordpress weblog, but more cloudy

PHP with SQL Azure

• SQL Server Driver for PHP at 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-premise apps or in Windows Azure

Page 35: Just another Wordpress weblog, but more cloudy

PHP with AppFabric

• AppFabric SDK for PHP developers athttp://dotnetservicesphp.codeplex.com/

• Supports PHP on service bus and access control

• Features• Expose on-premise apps on an external endpoint

without opening firewall• Pub/sub scenario’s• …

Page 36: Just another Wordpress weblog, but more cloudy

Finally!

Wordpress

Page 37: Just another Wordpress weblog, but more cloudy

• Blogging engine• Widely used• Easy installation• Gazillion plugins• Huge community around it• Free and open-source

Wordpress

Page 38: Just another Wordpress weblog, but more cloudy

• Runs on top of MySQL• Has no database abstraction layer• So: only runs on MySQL• Windows Azure has Table Storage and

SQL Azure

• I feel lots of work coming…

But...

Page 39: Just another Wordpress weblog, but more cloudy
Page 40: Just another Wordpress weblog, but more cloudy

• Easy way out• Wordpress on Windows Azure• MySQL on-premise / at other hoster

• Medium way out• Wordpress on Windows Azure• MySQL as well

• Hard way out• Wordpress on Windows Azure• MySQL out, SQL Azure in

There are ways around!

Page 41: Just another Wordpress weblog, but more cloudy

The easy way out

PHPWeb Role

VI P

Load

Bala

nce

r

Windows Azure Storage

MySQL

Windows Azure Platform

On-Premise / hosted

Page 42: Just another Wordpress weblog, but more cloudy

The easy way out

• Fresh Windows Azure project in Eclipse

• Fresh Wordpress.org download• Point wp-config.php to some

MySQL server• Package & deploy

Page 43: Just another Wordpress weblog, but more cloudy

The medium way out

PHPWeb Role

VI P

Load

Bala

nce

r

Windows Azure Storage

Windows Azure Platform

On-Premise / hosted

WorkerRolerunningMySQL

Page 44: Just another Wordpress weblog, but more cloudy

• Fresh Windows Azure project in Eclipse• Fresh Wordpress.org download• “Windows Azure MySQL PHP Solution Accelerator”

• http://code.msdn.microsoft.com/winazuremysqlphp

• Some configuration• Some anger• Some configuration• Point wp-config.php to the above MySQL server• Package & deploy

The medium way out

Page 45: Just another Wordpress weblog, but more cloudy

• BUT!• Instance count!• Pricing!• (5 x 240 EUR / month adds up...)

• Easier migration, but at a cost...

The medium way out

Page 46: Just another Wordpress weblog, but more cloudy

• Yes, you can run MySQL on Windows Azure!

• More “solution accelerators”:• MySQL

• http://code.msdn.microsoft.com/winazuremysqlphp

• Memcached• http://code.msdn.microsoft.com/winazurememcached

• MediaWiki• http://code.msdn.microsoft.com/winazuremediawiki

• Tomcat• http://code.msdn.microsoft.com/winazuretomcat

So...

Page 47: Just another Wordpress weblog, but more cloudy

The hard way out

PHPWeb Role

VI P

Load

Bala

nce

r

Windows Azure Storage

SQL Azure

Windows Azure Platform

On-Premise / hosted

Page 48: Just another Wordpress weblog, but more cloudy

• Fresh Windows Azure project in Eclipse• Fresh Wordpress.org download• Point wp-config.php to SQL Azure• Package & deploy• Fail!• There’s no SQL Server / SQL Azure

support in Wordpress, remember?

The hard way out

Page 49: Just another Wordpress weblog, but more cloudy

• MySQL queries all over the place!• “Data layer” (wp-db.php) = very thin• Raw MySQL queries passed from app to db• Logging• Some other stuff

• That’s nowhere near a database abstraction...

Have you ever looked at Wordpress?

Page 50: Just another Wordpress weblog, but more cloudy

• Required:• Re-build wp-db.php using SQL Server Driver for PHP

• http://www.microsoft.com/sqlserver/2005/en/us/PHP-Driver.aspx

• Options...• Re-write every single query in Wordpress

• Future proof?• Insane!

• Build a query translation tool, rewriting queries on-the-fly• Future proof!• Insane!

Strategic options

Page 51: Just another Wordpress weblog, but more cloudy

• Hooks in Wordpress• Wp-contents/db.php• Wp-includes/wp-db.php

• Strategy• Create wp-db.php class on top of SQL Server Driver for

PHP• http://www.microsoft.com/sqlserver/2005/en/us/PHP-Driver.aspx

• Create custom DB schema, compatible with SQL Server• Build a query translation tool, rewriting queries on-the-fly

• Someone at Microsoft had this laying around

Here’s what we did...

Page 52: Just another Wordpress weblog, but more cloudy

• Resources• Images, other file uploads, ...

• Normally stored on server disk• But this may not survive on Windows Azure...

• Solution• Plugin using Windows Azure SDK for PHP• Storing everything on Blob Storage• Serving everything from Blob Storage

• There’s a CDN available!

But there’s also... resources

Page 53: Just another Wordpress weblog, but more cloudy
Page 54: Just another Wordpress weblog, but more cloudy

DemoIf the Internet works...

Page 55: Just another Wordpress weblog, but more cloudy

Learn more!

Resources

Page 56: Just another Wordpress weblog, but more cloudy

Resources• Windows Azure

http://www.azure.com

• Windows Azure SDK for PHPhttp://phpazure.codeplex.com

• SQL Server Driver for PHPhttp://sqlsrvphp.codeplex.com

• AppFabric SDK for PHP developershttp://dotnetservicesphp.codeplex.com

• PDChttp://microsoftpdc.com

• PHP Architect December 2009 issuehttp://www.phparch.com

• Steve Marxhttp://blog.smarx.com/

• Clemens Vastershttp://vasters.com/clemensv/

• Simon Guesthttp://simonguest.com/blogs/smguest

• My bloghttp://blog.maartenballiauw.be/category/Azure.aspx

• RealDolmen blogs is running on Azure!http://www.realdolmenblogs.com

Page 57: Just another Wordpress weblog, but more cloudy

• Windows Azure is• Operating system (computing & storage)• SQL Azure• AppFabric• Codename projects• Your application and skills

• Hybrid applications

• It’s not that hard to do

Conclusion

Page 58: Just another Wordpress weblog, but more cloudy

• Is the source code available?• No, not at this time.

• Do I need Visual Studio / Eclipse?• Only for local debugging.

• Do I need Windows & the Windows Azure SDK?• Only for local debugging.

Before skipping to Q&A...

Page 59: Just another Wordpress weblog, but more cloudy

Q & AMaarten Balliauwhttp://blog.maartenballiauw.be

Page 61: Just another Wordpress weblog, but more cloudy
Page 62: Just another Wordpress weblog, but more cloudy