The Mobile Architect Morgan Skinner
Agenda Common Patterns and Designs Common Patterns and Designs Architecting Mobile Applications Architecting Mobile Applications Synchronization Web Services SQL CE MSMQ Performance Deployment
Common Patterns and Designs Document tested simple mechanisms Document tested simple mechanisms Provide common terminology for architects and developers Provide common terminology for architects and developers Promote Promote Re-use Flexibility Cohesion
Defining SOA Service-Oriented Architecture is an approach to organizing information technology in which data, logic, and infrastructure resources are accessed by routing messages between network interfaces Service-Oriented Architecture is an approach to organizing information technology in which data, logic, and infrastructure resources are accessed by routing messages between network interfaces Basic value proposition is to provide consistent, stable interfaces in front of diverse or volatile implementations Basic value proposition is to provide consistent, stable interfaces in front of diverse or volatile implementations Establish context for information exchange across organizations Encapsulate complexity within organizations Enable context-sensitive information processing
Microsoft’s Vision for SOA Service orientation will encapsulate and componentize processes and systems Service orientation will encapsulate and componentize processes and systems Help manage complexity Permit controlled change Support continuous improvement Business capabilities and business processes will be modeled as services Business capabilities and business processes will be modeled as services Organizations will expose touchpoints into these processes to both internal and extra-organizational actors Allows automation of processes that have defied automation until now On the path to the Agile Enterprise On the path to the Agile Enterprise
Three Tier Pattern Business Layer Data Access Layer Presentation Layer Order Entry Web Pages Reporting Web Pages Order Management Reporting Management User Management ADO.NET Order Data Access Reporting Data Access
Service Orientated Architecture Business Layer Data Access Layer Presentation Layer Order Entry Web Pages Reporting Web Pages Order Management Reporting Management User Management ADO.NET Order Data Access Reporting Data Access Service Interfaces Services Services Security
Mobile Architectures Need to address Need to address Communication From device to server or device Security Are communications secure? Is data secured? Performance Deployment All of the above can impact physical and logical Designs All of the above can impact physical and logical Designs
Server Applications Supports large number of devices Supports large number of devices Low cost deployment Low cost deployment Centralized logic Centralized logic Online only Online only Browser user interface Browser user interface ASP.NET Mobile Web Pages HTML for Pocket IE WML for WAP Browsers
Client Applications Targets a Smartclient Targets a Smartclient Deployment required Deployment required Can work disconnected Can work disconnected Rich user interface Rich user interface Server Web Services HTTP Channel MSMQ
Online / Offline Smartclient applications need to support online / offline Smartclient applications need to support online / offline Synchronization Options Synchronization Options One / Both ways Application / Database level
Synchronization Consider your applications requirements Consider your applications requirements Both Ways Both Ways Multi-user updates of data Web Services SQL CE Replication One Way One Way Mutually exclusive data Web Services MSMQ SQL CE Remote Data Access SMS
SynchronizationApplication User Interface Application Logic SQL Server CE DataSync Application Sync Data Sync High reuse of logic Slower synchronization Fast synchronization Low level of logic Data collisions Data Access Layer Business Layer Web Services UI ApplicationSync
Detecting Online / Offline
Web Services Synchronous Synchronous Good for small, quick packets of data Block the current thread Asynchronous Asynchronous Good for larger packets of data Callback when processing finished Check for exceptions due to connectivity issues Security Security Recommended to use SSL Digest or Clear Text authentication Currently no support for WSE Custom via SOAP headers
Web Services Considerations Store and Forward Store and Forward Web service requests cached Executed when network available Variable re-try algorithm Data Compression Data Compression GSM data costs Conserve bandwidth
Smart connected architecture Custom WS Proxy Network Test Store and Forward SmartClient Application Web Service Store Asynchronous Timed Event WebRequestCompleted Order Service Map Service
Data Compression Server side Server side Windows 2003 Server Enable compression and gzip.dll via MMC Modify metabase adding asmx to HcScriptFileExtensions for gzip and deflate compression filters Client side Client side Need to override GetWebRequest and GetWebResponse .NET Compact Framework SP1 Client applications need some additional coding to be able to exploit. Client applications need some additional coding to be able to exploit.
Client Data Compression public class GzipProxy : SoapHttpClientProtocol { protected override WebRequest GetWebRequest(System.Uri uri) { WebRequest req = base.GetWebRequest(uri); req.Headers.Add("Accept-Encoding", "gzip, deflate"); return req; } protected override WebResponse GetWebResponse(WebRequest req) { return new CompressedHttpWebResponse(req); }}
Web Services Store and Forward
DataSets Supported by Web services Supported by Web services Typed DataSet unsupported Typed DataSet unsupported Serializable to XML Serializable to XML Missing Merge() and GetChanges() Missing Merge() and GetChanges() Manual synchronization required Manual synchronization required
SQL Server CE 2.0 Runs on Pocket PC Runs on Pocket PC Smartphone version coming Smartphone version coming 1.5MB memory footprint 1.5MB memory footprint Compact Framework Support Compact Framework Support Authentication and Encryption Authentication and Encryption Connectivity Connectivity Remote Data Access - SQL7/2000 Merge Synchronization – SQL2000
Database Feature Set Rich functionality for small footprint Multi-column indexes Multi-column indexes Referential integrity Referential integrity Sub-selects (IN) Sub-selects (IN) Defaults Defaults Inner/outer joins Inner/outer joins One file database One file database Null support Null support Unicode support Unicode support Transactions Transactions Data-types Data-types Real, Numeric, NVarChar, NText, Image, Integer, DateTime, VarBinary, UniqueIdentifier, Money Having/group by Having/group by Seek on index Seek on index Set functions Set functions Identity attribute Identity attribute Local security - DB encryption (128bit) and database password Local security - DB encryption (128bit) and database password
OLEDB CE CLR /.NET CF QP/Cursor Engine/ES CE Data Access Storage Architecture Client Agent: Replication andRDA ADO CE v3.1 OLEDB / Replication API IIS CLIENTSERVER Storage Engine / Repl Tracking SQL CE Edition v2.0 eVB 3.0 eVC 3.0 OLEDB OLEDB Server Agent: Replication and Remote Data Access HTTP XML/BizTalk/CS b, CDPD, GSM, CDMA, TDMA, etc. Enterprise Backend Oracle / db2 / etc SQL Server CE Data Provider Native/Unmanaged Stack Data Provider SQL Server Client Data Provider ADO.NET VS.NET (VB.NET, C#).NET CF / Managed Stack TDS Ethernet Well Connected Occasionally Connected
Remote Data Access (RDA)
Remote Data Access
Merge Replication Based on SQL Server 2000 bi- directional implementation Based on SQL Server 2000 bi- directional implementation Ideal for mobile use Ideal for mobile use Update data on client and/or server Merge and resolve conflict based on server-side rules Easy synchronization when connected Flexible data partitioning: vertical, horizontal, and dynamic Flexible data partitioning: vertical, horizontal, and dynamic Anonymous pull subscriptions Anonymous pull subscriptions Auto Ranged Identity Support Auto Ranged Identity Support
SQL CE Replication
DataSet vs SQL CE DataSet SQL CE Inbuilt to Compact Framework Need to deploy Extra runtime RAM requirement Limited filter capability Rich ANSI SQL support Serializable to XML Persists on filesystem Supports Web services Remote data access and synchronization over HTTP Works with.NET Runtime Requires SQL Server Performance limited to smaller data Large databases up to 2GB No inbuilt security 128-bit Encryption support Client Access Licensing
Microsoft Message Queue Message Queue
MSMQ Implements asynchronous communications Implements asynchronous communications Provides guaranteed delivery, efficient routing, priority based messaging. Provides guaranteed delivery, efficient routing, priority based messaging. Usernames storage support roaming Usernames storage support roaming NIC tracking NIC tracking Transparent, salvageable storage Transparent, salvageable storage Small footprint ~150KB Small footprint ~150KB Support for private queues only Support for private queues only
Communication Options TransportSummary Web Services Internet Ready Industry standards / High level of interoperability Highly extensible Application synchronization SQL CE Internet Ready Designed for data manipulation Synchronization Enabled Can communicate to SQL Server Secure (Smartphone support coming) MSMQ Guaranteed delivery Extension of backend MSMQ systems Network tracking built in (Managed support coming)
Other Considerations Performance Performance Raw Application Perceived Response Backend Servers Security & Deployment Security & Deployment See Securing and Deploying your Mobile Application
Performance - WinForms Load and cache Forms in the background Load and cache Forms in the background Populate data separate from Form.Show() Pre-populate data, or Load data async to Form.Show() Parent controls top-down Parent controls top-down e.g. Form panels controls Keep event handling code tight Keep event handling code tight Process bigger operations asynchronously Blocking in event handlers will affect UI responsiveness
Performance - XML Use XmlTextReader and XmlTextWriter Use XmlTextReader and XmlTextWriter Smaller memory footprint than using XmlDocument XmlTextReader is a pull model parser which only reads a “window” of the data Design XML schema first, then code Design XML schema first, then code Understand the structure of your XML document Use elements to group Allows use of Skip() in XmlTextReader Use attributes to reduce size
Performance - Data If data is local…instead of DataSet… If data is local…instead of DataSet… Leverage SQL CE native in-proc database Query data using DataReader Use TableDirect command type for fast index searches Equivalent to “SELECT * FROM foo” Limit open SqlCeCommand/DataReaders Dispose when complete If data is remote… If data is remote… Use SQL CE replication When using Web Services Save data locally in SQL CE for faster access and storage Don’t save remote DataSets as XML to device If you do, save Schema as well
Performance - Server Aggregate multiple Web service calls where possible Aggregate multiple Web service calls where possible Stress test the server, find your limits Stress test the server, find your limits Implement stateless calls for web farms Implement stateless calls for web farms For large user base, partition times users can replicate SQL data For large user base, partition times users can replicate SQL data
Deployment Considerations Installation Installation CAB format for installation Desktop ActiveSync Web page URL Service Indication / Service Loading Messages SD/CF Card What is user base? Ongoing Ongoing How to ensure users are running latest versions?
Summary Store and Forward connectivity can help connected/disconnected environment Store and Forward connectivity can help connected/disconnected environment Web Services Web Services Standardised Extensible SQL CE SQL CE Designed for data manipulation Secure MSMQ MSMQ Extension of backend MSMQ systems Guaranteed delivery Design with performance in mind Design with performance in mind
Resources Patterns & Practices Patterns & Practices Compact Framework FAQ.NET Compact Framework FAQ default.aspx default.aspx SharpZipLib Compression Library (note licensing) SharpZipLib Compression Library (note licensing) spx spx IIS 6.0 HTTP Compression IIS 6.0 HTTP Compression rodtechnol/windowsserver2003/maintain/operate/iis6perf.asp rodtechnol/windowsserver2003/maintain/operate/iis6perf.asp SQL CE and SQL 2000 sp3a SQL CE and SQL 2000 sp3a MSMQ MSMQ
© Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.