<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Corey O'Connor</title>
    <description>The latest articles on DEV Community by Corey O'Connor (@coreyoconnor).</description>
    <link>https://dev.to/coreyoconnor</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F248456%2F7b77c826-b1e9-4762-9430-73db66b5f9d3.png</url>
      <title>DEV Community: Corey O'Connor</title>
      <link>https://dev.to/coreyoconnor</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/coreyoconnor"/>
    <language>en</language>
    <item>
      <title>Request Per Second is probably not it</title>
      <dc:creator>Corey O'Connor</dc:creator>
      <pubDate>Mon, 30 Mar 2020 19:09:43 +0000</pubDate>
      <link>https://dev.to/coreyoconnor/request-per-second-is-probably-not-it-aop</link>
      <guid>https://dev.to/coreyoconnor/request-per-second-is-probably-not-it-aop</guid>
      <description>&lt;p&gt;Let's start with a question: When you loaded this page did you experience the value the server's requests per second provided?&lt;/p&gt;

&lt;p&gt;The web browser sent a request to the domain. Which, for a standard stack, will look something like:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;domain name lookup to one or more addresses&lt;/li&gt;
&lt;li&gt;one of these addresses is selected &lt;/li&gt;
&lt;li&gt;request is sent to the selected address&lt;/li&gt;
&lt;li&gt;arrives at load balancer&lt;/li&gt;
&lt;li&gt;dispatched to one or more nodes&lt;/li&gt;
&lt;li&gt;that specific node(s) processes the request and replies&lt;/li&gt;
&lt;li&gt;load balancer replies with a selected request&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Where in that did the user experience "requests per second?". &lt;/p&gt;

&lt;p&gt;They didn't directly experience this for a (single) request. The user experience was of the latency. They did not directly experience maximum throughput or even per-node throughput. &lt;/p&gt;

&lt;p&gt;The service provider does receive value from per node throughput: Typically the higher throughput the more value per node in the system. Which, being dependent on value, depends on the customer. If the value per request warrants the cost then the throughput can be scaled.&lt;/p&gt;

&lt;p&gt;The service provider also receives value from the max throughput of the system: A higher max throughput the more customers can be supported without queueing.&lt;/p&gt;

&lt;p&gt;Imagine two scenarios:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A service that provides a security alarm system at 10k requests/sec. For one customer. With a latency of 20 days per request. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That would probably not provide the experience the customer expects from a security system :) Even if each request is high value; with that latency the value is unlikely to be realized.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A service that provides bank transactions at a latency of 1 second. With a per-node throughput of 1 request per second; the entire node processes only a single request at a time. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That might be entirely fine. Suppose each node cost 10$ for the duration of the request... but the request provided the company a value of 100$. I'd happily take that per-node throughput! The customer still experiences a fast transaction and the company can afford to horizontally scale and still profit.&lt;/p&gt;

&lt;p&gt;Certainly don't forget throughput when decided the value of an implementation. Good performance engineering practice would be to record this performance data. Even if not explicitly optimizing for this. Designing systems to provide value to customers is always the priority. Which likely means a focus on latency first and throughput second.&lt;/p&gt;

</description>
      <category>performance</category>
      <category>services</category>
    </item>
    <item>
      <title>"GraphQL vs REST" is ill-typed</title>
      <dc:creator>Corey O'Connor</dc:creator>
      <pubDate>Fri, 25 Oct 2019 23:26:26 +0000</pubDate>
      <link>https://dev.to/coreyoconnor/graphql-vs-rest-is-ill-typed-3392</link>
      <guid>https://dev.to/coreyoconnor/graphql-vs-rest-is-ill-typed-3392</guid>
      <description>&lt;h2&gt;
  
  
  What?
&lt;/h2&gt;

&lt;p&gt;"Wait just a minute.. What do you mean 'ill-typed'?"&lt;/p&gt;

&lt;p&gt;We see a lot of talk about "GraphQL vs REST". In fact, a quick search of DuckDuckGo shows pages of results on this exact subject. Yet, pedantically speaking, the statement is a false comparison.&lt;/p&gt;

&lt;p&gt;To be clear, those posts are typically discussing a specific class of REST server. And there are &lt;em&gt;huge&lt;/em&gt; advantages in using GraphQL. Let's dig into the details to understand what's actually going on. Which will inform us to better understand when to use each one.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quick Review
&lt;/h2&gt;

&lt;p&gt;What is REST?&lt;/p&gt;

&lt;p&gt;According to wikipedia, is a software architectural style for web services. &lt;/p&gt;

&lt;p&gt;What is GraphQL?&lt;/p&gt;

&lt;p&gt;According to wikipedia: a data query and manipulation language and runtime for APIs.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Types
&lt;/h2&gt;

&lt;p&gt;Right from the start we should notice that these definitions are different: One is referring to an architectural style. Which is, at most, a logical design. The other is referring to a language and runtime. Which is not a style but a physical design.&lt;/p&gt;

&lt;p&gt;Rather like comparing a Toyota against wheeled vehicles. "Toyota vs wheeled vehicles". Sounds kinda silly huh? "Toyota is a high quality implementation of wheeled vehicles" sounds better no?&lt;/p&gt;

&lt;p&gt;Indeed, GraphQL is a high quality (but narrow!) REST interface. :)&lt;/p&gt;

&lt;h2&gt;
  
  
  GraphQL &amp;lt;: REST ?
&lt;/h2&gt;

&lt;p&gt;Neither GraphQL or REST are limited to HTTP. That said, if we focus on HTTP we will find that GraphQL over HTTP adheres to the REST architectural style! The caveat is that the range of data (the resource) from the single &lt;code&gt;/graphql&lt;/code&gt; endpoint is large. Fortunately, how that endpoint behaves, the structure of the requests and response is &lt;em&gt;precise&lt;/em&gt;. This precision is ensured to a degree REST cannot provide in general.&lt;/p&gt;

&lt;h2&gt;
  
  
  So what is it?
&lt;/h2&gt;

&lt;p&gt;GraphQL is an Interface Description Language :)&lt;/p&gt;

&lt;p&gt;Pretty much what the wikipedia definition was! Still, it's not fair to assume it's "just another IDL". Unlike many other IDLs: GraphQL contains request composition and a clear specification of interpreter semantics. GraphQL also supports a high quality, REST compatible, transport. These are valuable innovations!&lt;/p&gt;

&lt;p&gt;Here we also find a start for describing where GraphQL is best applied: When a precise interface description is possible and required; When the domain of client requests requires composition. This is not always the case, but covers (in my experience) a large spectrum of services development.&lt;/p&gt;

&lt;h2&gt;
  
  
  Antipatterns
&lt;/h2&gt;

&lt;p&gt;To continue with attempting the comparison of "GraphQL and REST" without considering the application is risky. Naively assuming, from this false comparison, "GraphQL is better than REST" can result in a variety of issues&lt;/p&gt;

&lt;p&gt;Take a few situations where using GraphQL is questionable:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Serving binary data resources. GraphQL only has a single representation. Any data that is to be provided must be serialized in this representation. If there is a requirement to serve, for example, large images of various formats a GraphQL server would be costly and, frankly, re-implement a lot of REST.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Requirement for non-compositional requests. The composition aspect of GraphQL has a cost: The request must be interpreted accordingly. This is non trivial in general and can result in an unacceptable decrease in request cost bounds precision. As well as an increase in attack surface area.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Client complexity. Asymptotically, a minimal REST solution for certain applications is simpler than the equivalent GraphQL. This is an extreme comparisons tho. For most applications: reliable high quality client/server is a better choice than attempting to achieve the absolute optimal.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Concluding the Pedantry
&lt;/h2&gt;

&lt;p&gt;I hope you found this pedantic adventure interesting! In the end, GraphQL is another excellent and useful tool for our toolbox. However, let's not forget the real goal:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;To develop high quality services for our customers.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Always keep that in mind. Never settle no matter the hype. You'll do great! :D&lt;/p&gt;

</description>
      <category>graphql</category>
      <category>rest</category>
      <category>pedantry</category>
    </item>
    <item>
      <title>Questions to ask for CQRS</title>
      <dc:creator>Corey O'Connor</dc:creator>
      <pubDate>Wed, 16 Oct 2019 19:11:19 +0000</pubDate>
      <link>https://dev.to/coreyoconnor/questions-to-ask-for-cqrs-j7n</link>
      <guid>https://dev.to/coreyoconnor/questions-to-ask-for-cqrs-j7n</guid>
      <description>&lt;p&gt;CQRS stands for "Command Query Responsibility Segregation". The idea is an extension of the single responsibility principle applied to services:&lt;/p&gt;

&lt;p&gt;Command and Query are responsibilities of a system. By single responsibility principle, each of these responsibilities should be separate in the system.&lt;/p&gt;

&lt;p&gt;"How tho?" As with all design principles: giving the definition does not teach how to apply the principle. :)&lt;/p&gt;

&lt;p&gt;There are a lot of technologies that enable CQRS and these are worth an overview. I want to focus on the conceptual and logical first. The critical aspect of segregating command and query is useful even in design.&lt;/p&gt;

&lt;p&gt;For instance, a useful question: "Does this change the state of the system?". This likely resembles asking about purity to functional programmers. Yep, same idea :) Just applied early and often in the design. We should aim for a clear answer: Yes or no. If there isn't a clear answer then that likely indicates a poor separation of command and query.&lt;/p&gt;

&lt;p&gt;Is this an interesting topic for anybody else?&lt;/p&gt;

</description>
      <category>cqrs</category>
      <category>services</category>
      <category>design</category>
    </item>
  </channel>
</rss>
