microservices arch #MSA #phrasebook

  • SOA — is the ancestor
  • communication protocol — lightweight, but more costly than in-process communication
    • http — is commonly used for communication. Presumably not asynchronous
    • messaging — metaphor is often used for communication. I doubt there’s any MOM of message queue.
  • modularity
  • in-process — services can be hosted in a single process, but less common
  • cloud-friendly
  • scalability — hopefully better
  • devops — is a driver
    • testability — each service is easy to test, but not integration test
    • loosely coupled — decentralized, autonomous dev teams
    • deployment — is ideally independent for each service, and continuous, but overall system deployment is complicated

RESTful – phrase book

agile – …

coupling – less coupling between client and server, so server side changes are easier. I think SOAP requires client rebuild.

b2b – still dominated by SOAP

resource-oriented services – …

object – each URL logically represents an object, which you can Get (query), POST (create), PUT (update its content) or DELETE

Q: is REST simpler than traditional SOA or SOAP web services?

Q: the concept of “resource” — does it sometimes mean a database record?

RESTful^SOAP web service, briefly

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, use a POST, PUT, or DELETE to modify the object (in practice most of the services use a POST for this).

— soap vs REST (most interviewers probably focus here) —
* REST has only GET POST PUT DELETE; soap uses custom methods “getAge()” etc
* SOAP takes more dev effort, despite it’s name
* SOAP dominates enterprise apps

http web service in async mode? #le2YH

I think in my dotnet client/server system, we use WCF duplex extensively, meaning the server can push updates to the clients. Each client must subscribe though. I think this is exactly event-driven as you said.

I remember that if I put a break point in the client’s updateReceived() callback method, it gets hit automatically, without the client polling the server.

WCF duplex is a standard and mature feature in microsoft WCF.

The server endpoint uses https, and I believe it’s a web service.

Is it possible that the server push is implemented actually by client poll under the hood? I don’t think so. There’s a polling duplex ..

See http://msdn.microsoft.com/en-us/library/cc645027(v=vs.95).aspx

barebones web server in WCF: no app.config needed

using System;
using System.IO;
using System.ServiceModel;
using System.ServiceModel.Web;
namespace StaticWebServer
    public class WebServerHost
        public static void Main()
            var host = new WebServiceHost(typeof(StaticContentService),new Uri("http://localhost:8000/"));
            host.AddServiceEndpoint(typeof(IStaticContentService), new WebHttpBinding(), "");
                    new WebHttpBinding(){TransferMode = TransferMode.Streamed}, //to support large files like 70MB
            while (true) Console.ReadKey(true);
    public interface IStaticContentService
        Stream GetStaticContent(string content);
    /// <summary>
    /// In total, exactly *2* files deployed to C:/temp --
    /// Since I copied my compiled EXE (#1) to C:/temp, I needed a dummy C:/temp/www/a.html (#2).
    /// My browser could then show http://localhost:8000/www/a.html 
    /// - no config file -- You can remove app.config completely.
    /// - no dll, 
    /// - no IIS, 
    /// - no windows service.
    /// This WCF service is hosted in a console host.
    /// </summary>
    class StaticContentService : IStaticContentService
        [WebInvoke(Method = "GET", BodyStyle = WebMessageBodyStyle.Bare, UriTemplate = "/www/{*content}")]
        public Stream GetStaticContent(string content)
            Console.WriteLine("GetStaticContent() " + content);
            var response = WebOperationContext.Current.OutgoingResponse;
            string path = "www/" + (string.IsNullOrEmpty(content) ? "a.html" : content);
            if (File.Exists(path))
                response.ContentType = "text/html";
                response.StatusCode = System.Net.HttpStatusCode.OK;
                return File.Open(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
            response.StatusCode = System.Net.HttpStatusCode.NotFound;
            return null;

SERVICE means … in WCF, SOA etc

The concept of Service is central to wcf, but the “service” word is overloaded and vague. Here are a few distinct meanings

* windows service – daemon process. I think a unix network daemon is similar. However many windows services and unix daemons aren’t exposed to the network

* web service

* a remote callable [1] thingy, like a RPC. Any remote callable would qualify as a service!
** I feel web service qualifies as a type of of rpc service.
** a network daemon qualifies too.
** I feel in wcf, “service” means something like this.

Remote means you don’t call it like calling ToString() or localtime() within the same process.

Callable means on-demand, online, like a 24-hour call center, ready to serve callers.

How is it implemented? A base form is a Function or Procedure, but frequently there are “service OBJECTs” involved. In fact, the service objects are in the official Model of a service;) but I actually feel these objects are unnecessary to the basic concept of service. Nevertheless, “Service”, WebService, and SOA are big buzzwords, and these people just love the OO jargon. I feel these jargon terms add confusion without adding value. Too much abstraction can lead to health problems;)

In WCF, there are many jargon phrases containing “service”, which is a central concept in WCF.
* service host — the Process hosting the service.
* service reference — just a fancy name for the proxy class.
* ServiceEndpoint

who generates the local proxy for the remote

In any distributed-OO infrastructure (ejb, rmi, wcf, remoting…), someone needs to generate a proxy class based on the server-side
API. If you aren’t paying attention, you will not notice where, when and how exactly this is generated. But this is a crucial detail
not to be missed.

There’s a bit of ambiguity over 2 related concepts — Instantiating a proxy instance (at run-time) vs Generating a proxy class
source code before compiling.

(I like to say “client-side proxy” but the adjective is superfluous. )

— WCF —
Usually i generate the “service reference” from a wsdl or the service endpoint URL.