Building Highly Scalable Java Applications on Windows Azure - JavaOne S313978

  • Published on
    15-Jan-2015

  • View
    7.920

  • Download
    0

DESCRIPTION

Presentation delivered at JavaOne 2010. Talks about how to use Java to build highly scalable and reliable applications on Windows Azure.

Transcript

  • 1. Building Highly Scalable Java Applications on Windows Azure
    David Chou
    david.chou@microsoft.com
    blogs.msdn.com/dachou

2. >Introduction
Agenda
Overview of Windows Azure
Java How-to
Architecting for Scale
Whats Next
3. >Azure Overview
What is Windows Azure?
A cloud computing platform(as-a-service)
on-demand application platform capabilities
geo-distributed Microsoft data centers
automated, model-driven services provisioning and management
You manage code, data, content, policies, service models, etc.
not servers (unless you want to)
We manage the platform
application containers and services, distributed storage systems
service lifecycle, data replication and synchronization
server operating system, patching, monitoring, management
physical infrastructure, virtualization networking
security
fabric controller (automated, distributed service management system)
4. >Azure Overview
How this may be interesting to you
Not managing and interacting with server OS
less work for you
dont have to care it is Windows Server (you can if you want to)
but have to live with some limits and constraints
Some level of control
process isolation (runs inside your own VM/guest OS)
service and data geo-location
allocated capacity, scale on-demand
full spectrum of application architectures and programming models
You can run Java!
plus PHP, Python, Ruby, MySQL, memcached, etc.
and eventually anything that runs on Windows
5. > Azure Overview >Anatomy of a Windows Azure instance
Compute instance types: Web Role & Worker Role. Windows Azure applications are built with web role instances, worker role instances, or a combination of both.
Storage distributed storage systems that are highly consistent, reliable, and scalable.
Anatomy of a Windows Azure instance
HTTP/HTTPS
Each instance runs on its own VM (virtual machine) and local transient storage; replicated as needed
Guest VM
Guest VM
Guest VM
Host VM
Maintenance OS,
Hardware-optimized hypervisor
The Fabric Controller communicates with every server within the Fabric. It manages Windows Azure, monitors every application, decides where new applications should run optimizing hardware utilization.
6. > Azure Overview > Application Platform Services
Application Platform Services
Application
Marketplace
Information Marketplace
Personal Data Repository
Application Services
Workflow Hosting
Distributed Cache
Services Hosting
Frameworks
Claims-Based Identity
Federated Identities
Secure Token Service
Declarative Policies
Security
Registry
On-Premise Bridging
Service Bus
Connectivity
Transact-SQL
Data Synchronization
Relational Database
ADO.NET, ODBC, PHP
Data
Compute
C / C++
Win32
VHD
Dynamic Tabular Data
Blobs
Message Queues
Distributed File System
Content Distribution
Storage
7. > Azure Overview >Application Platform Services
Application Platform Services
Application Services
Hosting
Caching
Frameworks
WIF, ADFS2, MFG
Security
Access Control
Sydney
Connectivity
Service Bus
SQL Azure Data Sync
Houston
Data
VM Role
Compute
Table Storage
Blob Storage
Queue
Drive
Content Delivery Network
Storage
8. >Java How-To
Java and Windows Azure
Provide your JVM
any version or flavor that runs on Windows
Provide your code
no programming constraints (e.g., whitelisting libraries, execution time limit, multi-threading, etc.)
use existing frameworks
use your preferred tools (Eclipse, emacs, etc.)
File-based deployment
no OS-level installation(conceptually extracting a tar/zip with run.bat)
Windows Azure Worker Role sandbox
standard user (non-admin privileges; full trust environment)
native code execution (via launching sub-processes)
service end points (behind VIPs and load balancers)
9. > Java How-To > Boot-strapping
Some boot-strapping in C#
Kick-off process in WorkerRole.run()
get environment info (assigned end point ports, file locations)
set up local storage (if needed; for configuration, temp files, etc.)
configure diagnostics (Windows Server logging subsystem for monitoring)
launch sub-process(es) to run executable (launch the JVM)
Additional hooks (optional)
Manage role lifecycle
Handle dynamic configuration changes
Free tools
Visual Studio Express
Windows Azure Tools for Visual Studio
Windows Azure SDK
10. > Java How-To > Tomcat
Running Tomcat in Windows Azure
Service Instance
listen port(x)
Service Instance
Worker Role
Sub-Process
Tomcat
server.xml
Catalina
index.jsp
new Process()
RoleEntry Point
bind port(x)
get
runtime
info
SQL Database
JVM
http://instance:x
http://instance:y
Service
Bus
Access Control
http://app:80
Fabric Controller
Load Balancer
Table
Storage
Blob
Storage
Queue
11. > Java How-To > Jetty
Running Jetty in Windows Azure
Boot-strapping code in WorkerRole.run()
Service end point(s) in ServiceDefinition.csdef
string response = ""; try{ System.IO.StreamReadersr; string port = RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["HttpIn"].IPEndpoint.Port.ToString(); stringroleRoot = Environment.GetEnvironmentVariable("RoleRoot"); stringjettyHome = roleRoot + @"approotappjetty7"; stringjreHome = roleRoot + @"approotappjre6"; Processproc = newProcess(); proc.StartInfo.UseShellExecute = false; proc.StartInfo.RedirectStandardOutput = true; proc.StartInfo.FileName = String.Format(""{0}inava.exe"", jreHome); proc.StartInfo.Arguments = String.Format("-Djetty.port={0} -Djetty.home="{1}" -jar "{1}tart.jar"", port, jettyHome); proc.EnableRaisingEvents = false; proc.Start(); sr = proc.StandardOutput; response = sr.ReadToEnd();} catch(Exception ex) { response = ex.Message; Trace.TraceError(response); }

12. > Java How-To > Limitations
Current constraints
Platform
Dynamic networking
.cloudapp.net
no naked domain
CNAME re-direct from custom domain
sending traffic to loopback addresses not allowed and cannot open arbitrary ports
No OS-level access
Non-persistent local file system
allocate local storage directory
read-only: Windows directory, machine configuration files, service configuration files
Available registry resources
read-only: HKEY_CLASSES_ROOT, HKEY_LOCAL_MACHINE, HKEY_USERS, HKEY_CURRENT_CONFIG
full access: HKEY_CURRENT_USER
Java
Sandboxed networking
NIO (java.nio) not supported
engine and host-level clustering
JNDI, JMS, JMX, RMI, etc.
need to configure networking
Non-persistent local file system
logging, configuration, etc.
REST-based APIs to services
Table Storage schema-less (noSQL)
Blob Storage large files ( Platform Enhancements
Improvements on the way
Platform
Networking control
fixed VM ports (e.g., match external ports)
fixed and ranges for inter-role ports
inter-role communication access control
Plugins
diagnostics
Intellitrace
remote desktop
Full IIS
multiple websites in same role
virtual directories
applications, modules
Admin mode
OS-level installations and configurations
VM Role
run your own Windows Server-based VM
Java
Traditional deployment models
deploy your own Java EE stack
configure internal networking
More frameworks, packages, and extended languages
verify deployment and configuration
Solution accelerators
with bootstrapping and configuration
Java API support
map to lower-level services
14. > Java How-To >Platform Enhancements
Running Jetty with fixed VM ports
Boot-strapping code in WorkerRole.run()
Service end point(s) in ServiceDefinition.csdef
string response = ""; try{ System.IO.StreamReadersr; string port = "80"; stringroleRoot = Environment.GetEnvironmentVariable("RoleRoot"); stringjettyHome = roleRoot + @"approotappjetty7"; stringjreHome = roleRoot + @"approotappjre6"; Processproc = newProcess(); proc.StartInfo.UseShellExecute = false; proc.StartInfo.RedirectStandardOutput = true; proc.StartInfo.FileName = String.Format(""{0}inava.exe"", jreHome); proc.StartInfo.Arguments = String.Format("-Djetty.port={0} -Djetty.home="{1}" -jar "{1}tart.jar"", port, jettyHome); proc.EnableRaisingEvents = false; proc.Start(); sr = proc.StandardOutput; response = sr.ReadToEnd();} catch(Exception ex) { response = ex.Message; Trace.TraceError(response); }

15. > Java How-To >Platform Enhancements
Running Jetty with admin mode
Execute startup script in ServiceDefinition.csdef

16. > Java How-To >Platform Enhancements
Deployment Options
Worker Role
fabric sandbox native deployment
automated, need additional code
available now
Admin Mode
script-based installation and execution
automated, need scripts
available shortly
Remote Desktop
login remotely and manually install
manual, full control
available shortly
VM Role
host your own pre-configured VM image
automated, full control
available later
17. > Azure Overview >Ideal Scenarios
Whats this good for?
Web Applications

  • massive scale infrastructure

18. burst & overflow capacity 19. temporary, ad-hoc sitesService Applications

  • composite applications

20. mobile/client connected services 21. Web APIsHybrid Applications

  • component services

22. distributed processing 23. distributed data 24. external storageMedia Applications

  • CGI rendering

25. content transcoding 26. media streamingInformation Sharing

  • reference data

27. common data repositories 28. knowledge discovery & managementCollaborative Processes

  • multi-enterprise integration

29. B2B & e-commerce 30. supply chain management 31. health & life sciences 32. domain-specific services

Recommended

View more >