Armel caught up with Phillip Kruger from Red Hat to discuss GraphQL for Microservices architecture. Phillip is the lead contributor for Microprofile GraphQL and the Quarkus integration from Red Hat.
People usually ask me questions like; how can I use Blockchain for x thing? And one of those things is the General Data Protection Regulation (GDPR). If you are reading this now then it’s probably too late as GDPR comes into effect May 2018. Anyway, GDPR is not a technology issue but more of a process. It can be implemented using more standardized and mature technology such as RDBMS, Messaging Platform, Business Rules amongst other. What would you achieve by building your solution on the Blockchain? Well, in all frankness, not much. Would you store user data in the Blockhain? You could if you wanted to but how would handle the following GDPR articles (summary):
- Section 3: Rectification and Erasure
- Article 16: Right to Rectification
- Article 17: Right to Erasure (‘Right to Forgotten’)
People refers to the Blockchain technology as a decentralized (unless it’s a private deployment) immutable ledger which records all activities.
The Blockchain provides a way to build trust with multiple unknown parties. Most organizations know who they are dealing with on a daily basis: customer, partners and suppliers. Do they really need to provisioned data access for third-parties? No, they do not. So what would the Blockchain be used for? Blockchain is immutable, therefore updates are treated as new transactions and the old inaccurate data would still be available. This is direct violation to Article 16 and 17.
Another approach would be to deploy you Blockchain project in a mix environment where you application would be built in a multi-tiered architecture. In this approach, the user data would be stored in data store which accepts modification and also implements access controls. Due to the fact that the data store is mutable, it cannot be used to log activities which occurred against the data. This where the Blockchain ledger shines. Activities would be logged into the block as it happens; anonymised data of the person, the action taken and by who and timestamp. In this way, if the person requests article 16-17, then you do not have to worry about the data stored in the block. The data stored in the data store can be actioned accordingly. As an organisation who is looking to be GDPR compliant, there is no point in investing in a public Blockchain, a private deployment would suffice. The business process would have well defined rules for different outcomes. Changing the perspective now, as an architect, is the Bockchain really needed for such a simple task of creating immutable logs store? It would be simpler to create something, if not already available, which fit the requirements.
The above diagram illustrates, at high level, what a GDPR implementation on an immutable store would look.:
- The organisation would allow user to register online via various clients such as web or native clients.
- Organistation would store the user data into centralised data store such a NoSQL or RDBMS
- The organisation would implement an access and permission control to prevent unauthorized access and operation
- All operation will be logged into the immutable ledger
- JSON format of anonymized people data
- Type of operation
- Change delta
- Detail of user who carried out the operation
- Application metadata
- Third-party organisations requesting data access can be granted from API layer
- The organisation access control is check and validated
- A permission control will be in placed to make sure that only permissioned information is accessible
- All activities will be logged as above
The aforementioned architecture can be applied to most private deployment of Blockchain project is not only restricted to GDPR. The process removes the need for smart contracts, but that’s a topic for another article.
Thank you for reading and please share the article with your network and feel free to leave a comment.
This article, based on my experience, will discuss when to use SOAP or REST web services to expose your API to third party clients.
Web Services Demystified
Web services are part of the Services Oriented Architecture. Web services are used as the model for process decomposition and assembly. I have been involved in discussion where there were some misconception between web services and web API.
The W3C defines a Web Service generally as:
A software system designed to support interoperable machine-to-machine interaction over a network.
Web API also known as Server-Side Web API is a programmatic interface to a defined request-response message system, typically expressed in JSON or XML, which is exposed via the web – most commonly by means of an HTTP-based web server. (extracted from Wikipedia)
Based on the above definition, one can insinuate when SOAP should be used instead of REST and vice-versa but it is not as simple as it looks. We can agree that Web Services are not the same as Web API. Accessing an image over the web is not calling a web service but retrieving a web resources using is Universal Resource Identifier. HTML has a well-defined standard approach to serving resources to clients and does not require the use of web service in order to fulfill their request.
Why Use REST over SOAP
Developers are passionate people. Let’s briefly analyze some of the reasons they mentioned when considering REST over SOAP:
REST is easier than SOAP
I’m not sure what developers refer to when they argue that REST is easier than SOAP. Based on my experience, depending on the requirement, developing REST services can quickly become very complex just as any other SOA projects. What is your service abstracting from the client? What is the level of security required? Is your service a long running asynchronous process? And many other requirements will increase the level of complexity. Testability: apparently it easier to test RESTFul web services than their SOAP counter parts. This is only partially true; for simple REST services, developers only have to point their browser to the service endpoints and a result would be returned in the response. But what happens once you need to add the HTTP headers and passing of tokens, parameters validation… This is still testable but chances are you will require a plugin for your browser in order to test those features. If a plugin is required then the ease of testing is exactly the same as using SOAPUI for testing SOAP based services.
RESTFul Web Services serves JSON that is faster to parse than XML
Regarding the speed in processing the XML markup as opposed to JSON, a performance test conducted by David Lead, Lead Engineer at MarkLogic Inc, find out to be a myth.
REST is built for the Web
Well this is true according to Roy Fielding dissertation; after all he is credited with the creation of REST style architecture. REST, unlike SOAP, uses the underlying technology for transport and communication between clients and servers. The architecture style is optimized for the modern web architecture. The web has outgrown is initial requirements and this can be seen through HTML5 and web sockets standardization. The web has become a platform on its own right, maybe WebOS. Some applications will require server-side state saving such as financial applications to e-commerce.
When using REST over HTTP, it will utilize the features available in HTTP such as caching, security in terms of TLS and authentication. Architects know that dynamic resources should not be cached. Let’s discuss this with an example; we have a RESTFul web service to serve us some stock quotes when provided with a stock ticker. Stock quotes changes per milliseconds, if we make a request for BARC (Barclays Bank), there is a chance that the quote that we have receive a minute ago would be different in two minutes. This shows that we cannot always use the caching features implemented in the protocol. HTTP Caching be useful in client requests of static content but if the caching feature of HTTP is not enough for your requirements, then you should also evaluate SOAP as you will be building your own cache either way not relying on the protocol.
HTTP Verb Binding
HTTP verb binding is supposedly a feature worth discussing when comparing REST vs SOAP. Much of public facing API referred to as RESTFul are more REST-like and do not implement all HTTP verb in the manner they are supposed to. For example; when creating new resources, most developers use POST instead of PUT. Even deleting resources are sent through POST request instead of DELETE.
SOAP also defines a binding to the HTTP protocol. When binding to HTTP, all SOAP requests are sent through POST request.
Security is never mentioned when discussing the benefits of REST over SOAP. Two simples security is provided on the HTTP protocol layer such as basic authentication and communication encryption through TLS. SOAP security is well standardized through WS-SECURITY. HTTP is not secured, as seen in the news all the time, therefore web services relying on the protocol needs to implement their own rigorous security. Security goes beyond simple authentication and confidentiality, and also includes authorization and integrity. When it comes to ease of implementation, I believe that SOAP is that at the forefront.
This was meant to be a short blog post but it seems we got to passionate about the subject.
I accept that there are many other factors to consider when choosing SOAP vs REST but I will over simplify it here. For machine-to-machine communications such as business processing with BPEL, transaction security and integrity, I suggest using SOAP. SOAP binding to HTTP is possible and XML parsing is not noticeably slower than JSON on the browser. For building public facing API, REST is not the undisputed champion. Consider the actual application requirements and evaluate the benefits. People would say that REST protocol agnostic and work on anything that has URI is beside the point. According to its creator, REST was conceived for the evolution of the web. Most so-called RESTFul web services available on the internet are more truly REST-like as they do not follow the principle of the architectural style. One good thing about working with REST is that application do not need a service contract a la SOAP (WSDL). WADL was never standardized and I do not believe that developers would implement it. I remember looking for Twitter WADL to integrate it.
I will leave you to make your own conclusion. There is so much I can write in a blog post. Feel free to leave any comments to keep the discussion going.