.NET4.0 cloud computing project sample source - .NET4.0(C#)云计算程序实例源码:

Since cloud computing becoming a hot topic as major vendors, including top firms such as Amazon, Google, and Microsoft, jumped on the bandwagon with a wide-range of offerings, cloud computing has consistently stayed on the industry’s radar.

What's really happening? What does Cloud computing mean? Cloud computing platforms are growing in popularity, but why? So many questions strike in our mind. Stay cool! You will get a fair idea at the end of this session.

Computing Era

Charles Babbage is named as the father of the computer. He originated the concept of a programmable computer and is credited with inventing the first mechanical computer that eventually led to more complex designs. In terms of Computing Era, the below picture summarizes the fact:

ComputingEra
Mainframe Era

Mainframe systems are based on Centralized computing methodology. Mainframes are very large and expensive computers capable of supporting hundreds, or even thousands, of users simultaneously. In some ways, mainframes are more powerful than supercomputers because they support more simultaneous programs. But supercomputers can execute a single program faster than a mainframe. The distinction between small mainframes and minicomputers is vague, depending really on how the manufacturer wants to market its machines.

Personal Computer Era

Personal system is a small, relatively inexpensive computer designed for an individual user. In price, personal computers range anywhere from a few hundred dollars to thousands of dollars. All are based on the microprocessor technology that enables manufacturers to put an entire CPU on one chip. Businesses use personal computers for word processing, accounting, desktop publishing, and for running spreadsheet and database management applications. At home, the most popular use for personal computers is for playing games.

One of the first and most popular personal computers was the Apple II, introduced in 1977 by Apple Computer.

Mobility Era

Mobile system is based on anywhere, anytime, any user concept. A mobile operating system, also called a mobile OS, is an operating system that is specifically designed to run on mobile devices such as mobile phones, smartphones, PDAs, tablet computers and other handheld devices.

Ubiquity Era

Ubiquitous computing, or calm technology, is a paradigm shift where technology becomes virtually invisible in our lives. Instead of having a desktop or laptop machine, the technology we use will be embedded in our environment. Ubiquitous computing is roughly the opposite of virtual reality. Where virtual reality puts people inside a computer-generated world, ubiquitous computing forces the computer to live out here in the world with people.

Evolution of computing is drawn as below:
Evaluation

CIO - Point of View

Let's take a minute to think from Chief Information Office (CIO) of an Information Technology(IT) organization. Very simple question. Why should the firm move to the cloud? Hmm.. Pretty straight answer is living in the below diagram.

CIO View

Every IT firm has two major categories of spending:

  1. Acquisition (enhancements, new development, etc.)
  2. Operation (lights on, maintenance, etc.)

To enable the cutting edge solution and competitive products, the firm should spend more energy on the first category, whereas the normal/non niche organization used to focus on the second category.

Coming back to the cloud point, the predominant portion of operation cost will be eliminated by the cloud computing. Since 90% of the energy is spent on operating cost, most of their energy is relieved. I'm not saying that 90% will benull; but drastic reduction in the spending cost plus free up the operation work.

As CIO, we've dual benefits as mentioned below:

  1. Cost saving/reduction
  2. Free up the resource from lights on job

Cloud Fundamentals

Maslow's hierarchy of needs traverse from physiological needs to self actualization. In the similar way, Cloud fundamental is drawn with IaaS(Infrastructure As A Service), PaaS (Platform As A Service) and hierarchically as below:

CloudHierarchy

All these layers are built with Service Oriented Architecture (SOA) model.

IaaS

IaaS (Infrastructure As A Service) offers the hardware as the service, so that the firm can put whatever they want. Next two services PaaS and SaaS provide the applications to the customers. IaaS providers rent the resources such as Server space, network equipment, memory, CPU cycles and storage space. Key point is IaaS can be dynamically scale up and down based on the application resource needs. Multiple tenants can be on the equipment at the same time. Resources are typically billed based on a utility computing basis, so providers charge by how many resources are consumed.

PaaS

PaaS (Platform As A Service) supplies all resources required to build applications and services completely from the Internet, without having to download or install software. PaaS is also called as Cloudware.

PaaS services include application design, development, testing, deployment and hosting. Other services include team collaboration, web service integration, database integration, security, scalability, storage, state management and versioning. Downfall is lack of interoperability and portability among the various PaaS providers.

PaaS is expected to be used by many users simultaneously, it's designed to provide automatic facilities for concurrency management, scalability, fail over and security. It supports web development interfaces such as Simple Object Access Protocol (SOAP), REpresentataional State Transfer (REST), which allow the construction of multiple web services, sometimes called mashups. There are three different types of PaaS:

  • Add on development facilities
  • Stand alone environment
  • Application delivery-only environment
SaaS

SaaS (Software As A Service) is the model in which an application is hosted as a service to customers who access via Internet. When the software is hosted off-site, the customer doesn't have to maintain or support it. On the other hand, it's out of the customer hands when the hosting service decides to change it. The idea is that you use the software out of the box as is and do not need to make a lot of changes or require integration to the other system. The best example would be Microsoft Office Live, GMail for office, etc.

SaaS Benefits: One of the biggest benefits is costing less money than buying the application outright. The service provider can offer cheaper, more reliable applications than organizations can by themselves. Some other benefits are:

  • Better marketing
  • Reliability
  • Proven Security
  • More bandwidth
  • Smaller staff force

Referential Architecture

A reference architecture in the field of software architecture or enterprise architecture provides a proven template solution for architecture for a particular domain. It also provides a common vocabulary with which to discuss implementations, often with the aim to stress commonality. A reference software architecture is a software architecture where the structures and respective elements and relations provide templates for concrete architectures in a particular domain or in a family of software systems.

Reference architectures can be defined at different levels of abstraction. A highly abstract one might show different pieces of equipment on a communications network, each providing different functions. A lower level one might demonstrate the interactions of procedures (or methods) within a computer program defined to perform a very specific task.

The below diagram provides high level abstract of Cloud based applications in the corporate system.

Referential

Self Management Services

In general, Application is a program that runs once and closes after the completion of the given task; whereas services are ever running program.

Service is the application that has a critical purpose and should never (or rarely) be closed. Also, service provides good crash-recovery options, good notifications. It needs to always run, it's a service.

Service Management is monitoring and optimizing a service to ensure that it meets the critical outcomes the customer values and stakeholders want to provide.

In Cloud environment, 3 key services are managed for you with the below grid data:

SelfManagement

In the Microsoft cloud world, key technical zones like Application, Runtime, Operating System, Virtualization, Server, Database, Storage and Networking are listed as below:

MicrosoftZone

Cloud Storage Era

In cloud storage area, there are few interesting buzz words used as BigData, Horizontally Scalable, Schema free, etc. It all boiled down into a term named NoSQL (Not Only SQL). In fact, NoSQL is defined as next generation databases mostly addressing some of the points: being non-relational, distributed, open-source and horizontally scalable. The original intention has been modern web-scale databases. The movement began early 2009 and is growing rapidly. Often more characteristics apply as: schema-free, easy replication support, simple API, eventually consistent / BASE (not ACID), a huge data amount, and more.

Currently, there are 122+ NoSQL Databases at the industry. Largely, it covers:

  1. Wide column store like Hadoop, Cassandra, Hypertable,
  2. Document store like Mongo DB, Couch DB
  3. Tuple store like Azure table, Scalaris
  4. Graph database like Trinity, Bigdata
  5. Object database like Magma, Neo.

Cloud storage era is plotted in the below quatrand with the appropriate categories.

CloudStore

First Cloud Application

After the proper installations of Visual Studio 2010, AzureSDK, IIS, etc. the hello azure application is created in few seconds with the built-in wizard navigation. Quite simple steps to create the first Azure application with the above set up:

  • Launch Visual Studio 2010 as administrator.
  • Click File New Project, from the Visual C# installed Cloud templates.
  • Create Windows Azure Project with the solution name ‘FirstAzure’.
  • That's it; just click OK to launch a wizard.
  • From the wizard, add the ASP.NET Web Role in C# with ‘FirstAzure_WebRole’.
  • Run it (Ctrl+F5) and got the output ‘First Azure Application’.

I wrote a sample application with MVC template with 2 User Interface TABs; one for cloud news and another refers to my technical bloghttp://ganesansenthilvel.co.cc/.

Application Configuration

There are 2 key configuration files in Microsoft Azure cloud application. They are:

  1. Service Definition
  2. Service Configuration

The service model is determined by the settings listed in the ServiceDefinition.csdef file and configured in theServiceConfiguration.cscfg file. The definition file is packaged with the role binaries when the application is prepared for deployment. TheServiceConfiguration.cscfg file is deployed with the package and is used by Windows Azure to determine how the application should run.

Under roles, there's an entry called FirstAzure_WebRole. On opening it, the configuration contains Instances section withcount, vmsize. After updating the details, open ServiceDefinition.csdef file. Format looks like:

ServiceDefinition

By defining settings in the ServiceDefinition.csdef file, you can define the roles and resources for an application. An application that runs as a hosted service in Windows Azure implements one or more instances of the available role types. Within Windows Azure, running instances of a role are replicated across multiple computers to implement all or part of the functionality of the hosted service.

The root element ServiceConfiguration has only one attribute, namelyserviceName. The serviceName attribute is mandatory element inServiceConfiguration file. If you omit this attribute, Visual Studio is going to complain about your XML during compilation. The name of the service must match the name of the service in the service definition.ServiceConfiguration element can have only Role elements as children. Because the only role we have is ASP.NET Web role, we can see only oneRole element. In case our project contained another role, the Service Configuration file would reflect this fact as:

ServiceConfiguration

Role element also has a single name attribute which is required. Thename attribute represents the name of the service and must match the name of the service in the service definition defined in theWebRole element. The Role element can have three children elements:Instances, ConfigurationSettings and Certificates.Certificates are related to the security methodology followed in the related cloud app.

Management Portal

On building the first cloud application, it's time to host it in Microsoft Cloud center. As the first step, log into the azure home page (http://www.microsoft.com/windowsazure). On right top location, there's a link called SignIn. Using MSN account (ganscloud@hotmail.com), I created an account for Azure platform with extra small instance. As of now, it's more than sufficient for my proof of concept (POC) model. For more information on cloud hosting cost, please refer to the site (http://www.microsoft.com/windowsazure/offers/).

ManagementPortal - Click to enlarge image

As per the above screen, my account is successfully set up in cloud space and the domain is named as 'http://ganesansenthilvel.cloudapp.net/'. It's time to host after creating the account. To do so, we need to build the cloud application in Release mode of VS2010 IDE. It will create two files at bin\Release\Publish folder, namely:

  1. HelloAzure.cspkg (cloud app package file)
  2. ServiceConfiguration.cscfg (cloud app configuration file)

Cloud Application Deployment

On getting into cloud management portal, we have two regions to host our first cloud application. They are:

  1. Staging
  2. Production

Staging can be used as pre production, i.e., customer acceptance testing zone. Once the user signed off, Staging app can be easily shifted to Production zone by clicking the middle double arrowed button. Staging URLs are self generated numbers, where as production version is meaningful complete URL. In our app, it's ganesansenthilvel.cloudapp.net. Isn't it cool?

Buttons in the attached image are self descriptive. Upgrade button is used to importcspkg and cscfg files in the cloud space. Suspend button is used to stop the running cloud app. OS Settings is helpful to configure the cloud Operating System.

Deployment package is named as CSPack program, which zips service binaries along with two application configuration files.

 

Did you understand? 不知道你看懂了么? 有反馈欢迎给予直接反馈回复,或来信kingmax5421#gamil.com (以@代替#). 多谢批评指教~~~~~~~~~~~





Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐