how to get the most with windows and windows azure

32
How to get the most with Windows and Windows Azure Kanwaljeet Singla & Sumit Chawla Microsoft Corporation

Upload: kanwaljeet-singla

Post on 13-May-2015

3.798 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: How to get the most with Windows and Windows Azure

How to get the most with Windows and Windows Azure

Kanwaljeet Singla & Sumit ChawlaMicrosoft Corporation

Page 2: How to get the most with Windows and Windows Azure

Agenda• PHP on Windows

– How to make PHP fly on IIS– SQL Server Driver for PHP– Web Platform Installer– Community

• PHP on Windows Azure– What is the Microsoft Cloud?– Deploying a PHP application to the cloud– Windows Azure SDKs and Tools for PHP

• Questions / Open Discussion

Page 3: How to get the most with Windows and Windows Azure

FastCGI

• Fast and Reliable.• v1.0 released in Oct 2007• v1.5 released in Nov 2009• Consistent set of features across all IIS versions:

– FastCGI in IIS 7.5 – new features included in OS– FastCGI in IIS 7.0 – install the FastCGI update (

http://www.iis.net/expand/FastCGI)– FastCGI in IIS 5.1/IIS 6.0 – install FastCGI 1.5 extension

Recommended way of running PHP on Windows

Page 4: How to get the most with Windows and Windows Azure

FastCGI (cont.)

• New features:– Auto-tuning of maxInstances– Automatic recycling of PHP processes when php.ini

changes• Useful tips

– Use latest version of FastCGI and turn on dynamic maxInstances and monitorChangesTo features

– Increase InstanceMaxRequests value and match the value to PHP_FCGI_MAX_REQUESTS environment variable

Page 5: How to get the most with Windows and Windows Azure

PHP 5.3

• PHP 5.3 improvements:– Using VC9 compiler (PHP 5.2 used VC6)– Optimized API calls (using Win32 instead of POSIX)– All PHP libraries built from the source code– Compatibility fixes

• Windows builds are available at:– http://windows.php.net/

From: http://ilia.ws/files/Confoo2010_PHP53.pdf “Substantial performance improvements on Windows (40% +)”

Page 6: How to get the most with Windows and Windows Azure

WinCache 1.0

• PHP Accelerator optimized for Windows– Opcode cache– File cache– Resolve path cache

• Download from:– http://www.iis.net/expand/WinCacheForPhp

• Contributed by MS to PECL:– Source code on http://pecl.php.net/wincache/ – Documentation on http://www.php.net/wincache/ – BSD license

Contributions are welcome!

Page 7: How to get the most with Windows and Windows Azure

Why use opcode cache?

To serve index.php in WordPress, PHP has to read, parse, compile and execute more than 100 php files!

Page 8: How to get the most with Windows and Windows Azure

WinCache 1.0

• Useful Tips:– Increase maxInstances or use dynamic

maxInstances– Adjust file cache and opcode cache sizes. Use

wincache.php to study cache usage– Keep wincache.chkinterval value high on

production servers and low on development machines

Restrict access to wincache.php by using built-inauthentication or web server authentication

Page 9: How to get the most with Windows and Windows Azure

WinCache 1.1

• Beta2 released in April 2010– Object cache – Compatible with APC APIs– WinCache session handler– File change notification support– Function hooks

• Useful Tips:– Turn on user cache if application supports it– Port from existing code which uses APC’s object cache– Keep file change notification turned on– Turn on session handler if not running a web farm

Page 10: How to get the most with Windows and Windows Azure

SQL Server Driver for PHP• Thin layer over SNAC (ODBC)

– Single functional layer with thin API layer on top

PDO API

SQL Server Native Client (ODBC)

Core Functional Layer

php_sqlsrv.dll php_pdo_sqlsrv.dllphp_sqlsrv.dll

SQLSRV Native API

SQLSRV Native API

SQL Server Driver for PHP 1.1

SQL Server Driver for PHP 2.0

Page 11: How to get the most with Windows and Windows Azure

SQL Server Driver for PHP Tips• Scrollable Cursor: scrollable but slower

– Use sqlsrv_has_rows() w/ CURSOR_FORWARD if you only need to check if there’s data in the resultset, it’s faster and doesn’t move the cursor

– If scrollable required, consider CURSOR_STATIC first• WarningsReturnAsErrors: ON by default

– Remember to turn it OFF in deployment– Should we change default to OFF?

• UTF-8 encoding– The default for PDO, available per col/param– Should we make this the default for sqlsrv_xxx?

• Use transactions for DDL to improve performance

Page 12: How to get the most with Windows and Windows Azure

SQL Server Query Tips• Range query:

– SELECT * FROM table ORDER BY date LIMIT 20,10

• Use TOP & ROW_NUMBER• SELECT sub2.*,

ROW_NUMBER() OVER(ORDER BY sub2._l2) AS _lFROM ( SELECT 1 AS _l2, sub1.* FROM ( SELECT TOP(30) * FROM table ORDER BY date ) AS sub1) as sub2WHERE _l BETWEEN 20 AND 30;

• SELECT * FROM (SELECT *, ROW_NUMBER() OVER(ORDER BY date)

AS _l FROM table) AS tWHERE _l BETWEEN 20 AND 30ORDER BY _l;

Page 13: How to get the most with Windows and Windows Azure

Web Platform Installer

• Easy way to install IIS components, PHP 5.2, PHP and Asp.Net web applications etc.

• Demo

PHP 5.3 will be offered through WebPI soon

Page 14: How to get the most with Windows and Windows Azure

Community participation

• WinCache is on PECL and SQL driver for PHP is on codeplex

• IIS and WinCache documentation on php.net• Participating on PHP newsgroups• Working with PHP developers to improve PHP

and PHP installer• Working with PHP application developers to

integrate URLRewrite, WinCache

Page 15: How to get the most with Windows and Windows Azure

Miscellaneous tips

• Set IP address of MySql machine in hosts file• Build PHP yourself and statically link WinCache• Compile and optimize using PGO for maximum

performance• URLRewrite

– Includes htaccess importer• Use IIS warm-up module to fill opcode cache

before first request arrives

Page 16: How to get the most with Windows and Windows Azure

It’s an Operating System In the Cloud.Simple Answer?

What is Windows Azure?

Windows Azure: operating system as an online serviceMicrosoft SQL Azure: fully relational cloud database solutionWindows Azure platform AppFabric: connects cloud services and on-premises applicationsMicrosoft Codename “Dallas”: information marketplace for data and web services

Page 17: How to get the most with Windows and Windows Azure

Microsoft Data CentersVision Go Inside Energy EfficientContainers

San Antonio

Chicago

Dublin

Amsterdam

Hong Kong

Singapore

North American Data Centers European Data Centers Asian Data Centers

Washington

Page 18: How to get the most with Windows and Windows Azure

The Windows Azure Model

http://www.microsoft.com/windowsazure/windowsazure

Page 19: How to get the most with Windows and Windows Azure

Windows Azure RolesThis is how your code runs in the cloud

Storage Services

Public Internet

Web RoleLoad

Balancer

• Load balanced Web Farm• IIS7 web server• Serves HTTP/HTTPS requests

Storage Service

Public Internet

Worker Role

• No inbound connections by default

• Typically used to process background tasks by reading requests from storage queue

Web Role Worker Role

[1..n] [1..m]

Page 20: How to get the most with Windows and Windows Azure

SQL AzureRelational Database in the cloud

• Based on SQL Server technologies• Scale databases up or down based on business needs • No need to install or patch software or other physical

administration • Automatic high availability and fault tolerance • Simple provisioning and deployment of multiple

databases http://www.microsoft.com/windowsazure/sqlazure

Page 21: How to get the most with Windows and Windows Azure

PHP Web App

MySQL

What about hosting my PHP + MySQL on Windows Azure?

MySQL Solution Accelerator [>=2 VM Instances]http://code.msdn.microsoft.com/winazuremysqlphphttp://microsoftpdc.com/Sessions/SVC51http://live.visitmix.com/MIX10/Sessions/SVC12

Hosted Web Core Worker Role [1 VM Instance]http://code.msdn.microsoft.com/hwcworker

Solutions

• Yes, you can do it• If you do, you are using

Windows Azure only as an infrastructure service

• This means you are responsible for managing the infrastructure

Page 22: How to get the most with Windows and Windows Azure

Deploying PHP Apps to Windows Azure

PHP Application

PHP Core

PHP Extensions

Windows Azure Command-line Tool for PHP

Windows Azure Deployment Package

(cspkg + configuration)

http://azurephptools.codeplex.com/ Download at

Page 23: How to get the most with Windows and Windows Azure

• Create new applications or convert existing PHP applications to Windows Azure applications

• Deploy to Local Development Fabric or the Windows Azure Cloud

• No IDE required

http://azurephptools.codeplex.com/ Download at

Windows Azure Command-line Tool for PHP

Page 24: How to get the most with Windows and Windows Azure

http://wordpress.visitmix.com

Deploy WordPress to Windows Azure

Demo

Page 25: How to get the most with Windows and Windows Azure

• Worker Role Support• Ability to attach an external

drive to your Windows Azure Instance [aka X-Drive]

http://azurephptools.codeplex.com/ Download at

Windows Azure Command-line Tool for PHP

What’s new

Page 26: How to get the most with Windows and Windows Azure

Browser

LB

Web Role

Queue

12 3

4

5

6

7

Worker Role

Blob Store

Running background tasks with PHP on Windows Azurehttp://phpworkerdemo.cloudapp.net/

Page 27: How to get the most with Windows and Windows Azure

PHP Runtime

Other Windows Azure SDKs and ToolsWindows Azure SDK for PHP

Logical architecture • Overview– Enables PHP developers to take

advantage of the Microsoft Cloud Services Platform – Windows Azure.

• Features– PHP classes for Windows Azure

Blobs, Tables & Queues (for CRUD operations)

– Helper Classes for HTTP transport, AuhN/AuthZ, REST & Error Management

– Manageability, Instrumentation & Logging support

• Also Distributed via Zend Framework

• Project Sitehttp://www.codeplex.com/PHPAzure

Deployment scenarios

PHP SDK for Windows AzureBlobs, Tables, Queues

Your PHP application

Compute Storage Manage

REST XML

Any internet connected Server

PHP RuntimeREST

REST

Page 28: How to get the most with Windows and Windows Azure

+ Fast CGI + Eclipse IDE + PHP SDK for Windows Azure

1 2

3

4

Other Windows Azure SDKS and ToolsWindows Azure Eclipse Tools

Page 29: How to get the most with Windows and Windows Azure

Summary

Recap• PHP on Windows has come a long way in the last few years• We are committed to improving the PHP experience on

Windows• Windows Azure Platform offers scalable operating system as

service and relational database services in the cloud• Windows Azure is more than a hosting infrastructure• There are several SDKs and Tools available for developing and

deploying PHP Apps to the Microsoft Cloud

Call to Action• What scenarios are important to you?• What would make Windows Azure more interesting for you?

Page 30: How to get the most with Windows and Windows Azure

Additional Resources

• PHP on Windows– http://windows.php.net/– http://php.iis.net/– http://www.microsoft.com/web/php/– http://forums.iis.net/– http://www.ksingla.net– php.windows mailing list

• PHP Interoperability– http://www.interoperabilitybridges.com – http://www.azure.com/interoperability – http://blogs.msdn.com/interoperability

Page 31: How to get the most with Windows and Windows Azure

Contact Information

• Kanwaljeet Singla (IIS and WinCache Developer)– [email protected]– http://twitter.com/kjsingla – http://blogs.iis.net/ksingla/

• Ruslan Yakushev (IIS Program Manager)– [email protected]– http://twitter.com/ruslany– http://ruslany.net/

• Venkat Raman Don (IIS and WinCache Tester)– [email protected]– http://blogs.iis.net/donraman

• Pierre Joye (PHP Core Developer)– [email protected]– http://twitter.com/PierreJoye

• Mark Brown (IIS Product Manager)– http://twitter.com/markjbrown – http://blogs.msdn.com/markbrown/

PHP on Windows PHP Interoperability• Sumit Chawla

[email protected] • Jean-Christophe

[email protected]• Vijay Rajagopalan

[email protected] • Karri Dunn

[email protected] • Jas Sandhu

[email protected] • Interoperability Team Blog

– http://blogss.msdn.com/interoperability

Page 32: How to get the most with Windows and Windows Azure

Questions