Pattern: Microservice Architecture

Forces

  • There is a team of developers working on the application
  • New team members must quickly become productive
  • The application must be easy to understand and modify
  • You want to practice continuous deployment of the application
  • You must run multiple copies of the application on multiple machines in order to satisfy scalability and availability requirements
  • You want to take advantage of emerging technologies (frameworks, programming languages, etc)

Solution

Define an architecture that structures the application as a set of loosely coupled, collaborating services. This approach corresponds to the Y-axis of the Scale Cube. Each service implements a set of narrowly, related functions. For example, an application might consist of services such as the order management service, the customer management service etc.

Services communicate using either synchronous protocols such as HTTP/REST or asynchronous protocols such as AMQP. Services can be developed and deployed independently of one another. Each service has its own database in order to be decoupled from other services. Data consistency between services is maintained using an event-driven architecture

Examples

Fictitious e-commerce application

Let’s imagine that you are building an e-commerce application that takes orders from customers, verifies inventory and available credit, and ships them. The application consists of several components including the StoreFrontUI, which implements the user interface, along with some backend services for checking credit, maintaining inventory and shipping orders. The application consists of a set of services.

 

 

Ref: microservices.io/patterns/microservices.html

Software engineers should also act as Tech Support

Important for the product based organization, Software engineers should also act as Tech Support at least twice a month.

  • Fights “Development in a vacuum” syndrome. It’s valuable to gain exposure to how users use the app. Until I finally saw this as a young developer, I didn’t realize what a crappy UI developer I was. All I cared about was coding and not design, analysis or the user’s perspective.
  • Delivery product to the target audience in a better way. They can simply the UX issues for the customer which cause more customer satisfaction.
  • Software engineers can also realize the pain of Support Staff and simplify his life after delivering a better product.
  • Developers that are not as good as they think they are can be humbled (although there’s no guarantee you’ll get this benefit; some devs are truly oblivious, selfish, and stubborn).
  • Developers will gain domain knowledge. This is critical if your developers are to eventually become better at identifying and filling in the gaps the business analysis phase (assuming there is any) misses.
  • Good support is a marketing point. If you do it well, clients will come to appreciate it. And a well-rounded developer with communication skills and domain knowledge is capable of doing this well. However, I would still prefer that applications be of high enough quality that they don’t need support. Superior quality is its own form of customer support (and also a marketing point).

Why Git-Tag is important for Release

Tag and Branches

What’s the difference between tags and branches? The workspace is (almost always) associated with a branch, called master by default. When it is, a commit will automatically update the master reference to point to that new commit; in other words, branches are mutable references.

What is Git Tag?

A tag, on the other hand, is created to point to a specific commit and thereafter does not change, even if the branch moves on. In other words, tags are immutable references.

Git has two flavours of tags;

  • annotated and
  • non-annotated.

When using them, there is little difference between the two; both will allow you to refer to a specific commit in a repository. An annotated tag creates an additional tag object in the Git repository, which allows you to store information associated with the tag itself. This may include release notes, the meta-information about the release, and optionally a signature to verify the authenticity of the commit to which it points.

 

Why use Git tag?

Git tags are like milestones, markers or a specific point in the repo’s history marked as significant. Tags are usually used to mark stable releases or achievement of very important milestones.

Tags can help the users of the repo to easily navigate to the important parts of the code history like release points. For example, on Github, you can easily grab archive of “tags” in the current repo.

 

Commands dealing with Tags

List tags:
git tag

Search in tags:
git tag -l v1.*

That will display tags starting with “v1.” – use regex and your common sense to do complex queries. This can help you narrow down your query in case you have plenty of tags in the repo.

View a tag:
git show v1.4

Note: The command doesn’t have “tag” in it. 🙂

Adding tags:
git tag -a v1.0.0 -m ‘version 1’

The “-a” denotes an annotated tag – means it’s stored as a full object in the git database where as a non annotated tag is just a pointer to a specific commit. Just drop the “-a” to create normal tags. The “-m” option is of course obvious, it allows you to add a message to the annotated tag.

Adding Tags later:
git tag -a v1.2 9fceb02

This will add the “v1.2” tag to the commit marked by “9fceb02”. “git log” will help you get the checksum of the commit.

Pushing Tags to remote branch:
git push –tags

PS: Git tags are not pushed automatically with generic “git push” command. You must push the tags separately.

Deleting a tag:
git tag -d v1.0.0

That will delete the tag v1.0.0.

These are the very common uses of Git tags. Look at the git manual for more complex stuff you can do with taggin

The Three Ways to Cloud Compute

 

SAAS – Software as a Service

Best Part

  1. Accessible from anywhere through internet
  2. Good for the collaborative environment
  3. Subscription basis can save cost instead of investing a huge money
  4. Reduce Infrastructure Cost, Maintenance Cost, etc.

Need to Think

  • Genric Application sometimes not suitable for all business
  • But can be archive though customized plugin

PAAS – Platform as a Service

Provide environment and tools for creating new online application

Example: Google App Engine, Iphone IOS, Microsoft Azure Platform

Best Part

  • Rapid development at low cost
  • Private and public deployments

Need to Think

  • Limited developer to provider languages and tools
  • Risk of vendor lock-in

IAAS – Infrastructure as a Service

Allow existing applications to sun on a cloud’s hardware

Example- Shared hosting.

SOAP

SOAP, originally defined as Simple Object Access Protocol. It relies on Extensible Markup Language (XML) for its message format.SOAP has been adopted as the standard for Web services, and applications from major vendors have developed SOAP APIs for their products, thus making software systems integration easier.

Transport methods

Both SMTP and HTTP are valid application layer protocols used as Transport for SOAP

Message format

POST /InStock HTTP/1.1
Host: www.example.org
Content-Type: application/soap+xml; charset=utf-8
Content-Length: 299
SOAPAction: “http://www.w3.org/2003/05/soap-envelope”

<?xml version=”1.0″?>
<soap:Envelope xmlns:soap=”http://www.w3.org/2003/05/soap-envelope”>
<soap:Header>
</soap:Header>
<soap:Body>
<m:GetStockPrice xmlns:m=”http://www.example.org/stock”>
<m:StockName>IBM</m:StockName>
</m:GetStockPrice>
</soap:Body>
</soap:Envelope>

Advantages

  • SOAP is versatile enough to allow for the use of different transport protocols. The standard stacks use HTTP as a transport protocol, but other protocols such as JMS[7] and SMTP[8] are also usable.
  • Since the SOAP model tunnels fine in the HTTP get/response model, it can tunnel easily over existing firewalls and proxies, without modifications to the SOAP protocol, and can use the existing infrastructure.

Disadvantages

  • Because of the verbose XML format, SOAP can be considerably slower than competing middleware technologies such as CORBA.
  • When relying on HTTP as a transport protocol and not using WS-Addressing or an ESB, the roles of the interacting parties are fixed. Only one party (the client) can use the services of the other. Developers must use polling instead of notification in these common cases.

 

To start, First enabling the php SOAP extension  php_soap

When programming some soap server set the “soap.wsdl_cache_enabled” directive in php.ini file to 0:

soap.wsdl_cache_enabled=0

php Soap Client Call

<?php
$client = new SoapClient(“some.wsdl”);
$client = new SoapClient(“some.wsdl”, array(‘soap_version’   => SOAP_1_2));
$client = new SoapClient(“some.wsdl”, array(‘login’          => “some_name”,
‘password’       => “some_password”));

$client = new SoapClient(“some.wsdl”, array(‘proxy_host’     => “localhost”,
‘proxy_port’     => 8080));

$client = new SoapClient(“some.wsdl”, array(‘proxy_host’     => “localhost”,
‘proxy_port’     => 8080,
‘proxy_login’    => “some_name”,
‘proxy_password’ => “some_password”));

$client = new SoapClient(“some.wsdl”, array(‘local_cert’     => “cert_key.pem”));

$client = new SoapClient(null, array(‘location’ => “http://localhost/soap.php”,
‘uri’      => “http://test-uri/”));

$client = new SoapClient(null, array(‘location’ => “http://localhost/soap.php”,
‘uri’      => “http://test-uri/”,
‘style’    => SOAP_DOCUMENT,
‘use’      => SOAP_LITERAL));

$client = new SoapClient(“some.wsdl”,
array(‘compression’ => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP));

$server = new SoapClient(“some.wsdl”, array(‘encoding’=>’ISO-8859-1’));

class MyBook {
public $title;
public $author;
}

$server = new SoapClient(“books.wsdl”, array(‘classmap’ => array(‘book’ => “MyBook”)));

?>

1
<code> 

.

REST Web Service & SOAP

Short Comparison with REST and SOAP

What is a REST Web Service

The acronym REST stands for Representational State Transfer, this basically means that each unique URL is a representation of some object. You can get the contents of that object using an HTTP GET, to delete it, you then might use a POST, PUT, or DELETE to modify the object (in practice most of the services use a POST for this).

Who’s using REST?

All of Yahoo’s web services use REST, including Flickr, del.icio.us API uses it, pubsub, bloglines, technorati, and both eBay, and Amazon have web services for both REST and SOAP.

Who’s using SOAP?

Google seams to be consistent in implementing their web services to use SOAP, with the exception of Blogger, which uses XML-RPC. You will find SOAP web services in lots of enterprise software as well.

REST vs SOAP

As you may have noticed the companies I mentioned that are using REST api’s haven’t been around for very long, and their apis came out this year mostly. So REST is definitely the trendy way to create a web service, if creating web services could ever be trendy (lets face it you use soap to wash, and you rest when your tired). The main advantages of REST web services are:

  • Lightweight – not a lot of extra xml markup
  • Human Readable Results
  • Easy to build – no toolkits required

SOAP also has some advantages:

  • Easy to consume – sometimes
  • Rigid – type checking, adheres to a contract
  • Development tools

.