<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Thatcher Peskens on Medium]]></title>
        <description><![CDATA[Stories by Thatcher Peskens on Medium]]></description>
        <link>https://medium.com/@thatcher?source=rss-6bb2705ccda0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*xvytataiHiSc_IGgQwAyCg.jpeg</url>
            <title>Stories by Thatcher Peskens on Medium</title>
            <link>https://medium.com/@thatcher?source=rss-6bb2705ccda0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 16:09:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@thatcher/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[It’s time to do something about dirty clouds]]></title>
            <link>https://medium.com/@thatcher/its-time-to-do-something-about-dirty-clouds-4728474a4e2f?source=rss-6bb2705ccda0------2</link>
            <guid isPermaLink="false">https://medium.com/p/4728474a4e2f</guid>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[environment]]></category>
            <dc:creator><![CDATA[Thatcher Peskens]]></dc:creator>
            <pubDate>Wed, 10 Jun 2020 08:52:03 GMT</pubDate>
            <atom:updated>2020-07-13T11:20:45.526Z</atom:updated>
            <content:encoded><![CDATA[<p>Especially in these Corona days, we are all quite happy that we can do everything online. It’s all been doable by a global shift to create online services for everything, which we happily call The Cloud.</p><p>What often goes unnoticed, is that these services run on <em>real</em> computers, take up <em>real</em> space, and use <em>real</em> energy. Lots of energy. All of this energy is turned into heat, which is disposed of and typically means using additional energy to cool off all of the servers. At the same time, elsewhere on the grid, we use primary energy to generate heat for our house, our shower, the office, a pool, the gym, and everything else.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/0*dOw_1q_sb14qR_xU.jpeg" /></figure><p>Simply put: the cloud is built on data centers and data centers have a massive carbon footprint. We need a sustainable alternative. I’m one of four guys on a journey in which we feel we can build a great company, protect the environment, and have fun doing it by providing that alternative.</p><p>At GreenEdge we’re building a distributed cloud platform, housed at locations where the excess heat the servers produce is reused immediately. This allows us to use energy up to 90% more efficiently than regular cloud providers and offer a truly green option.</p><h3>The problems we’re trying to solve</h3><p><strong>Wasting Energy</strong></p><p>Data centers account for roughly 1% of all electricity used globally. The Dutch Datacenter Association says it’s closer to 3% in the Netherlands. To put that into perspective: 3% is almost as much electricity as the entire city of Amsterdam uses, except for the 10% used by data centers themselves.</p><p>And it’s growing. In fact, compute usage is growing exponentially. Over the past few years, two factors have managed to delay this translating into a spike in energy usage. First, moving compute in data centers to multi-tenant cloud providers, which allows for more efficient usage of the available computers and cooling. And second, chips were getting exponentially more efficient.</p><p>These methods have run their course. Most services already run in the cloud and both AMD and Intel now use increasingly more power. Data center energy usage is set to rise sharply, what’s needed are innovations in power-saving.</p><p><strong>Having a Green Option</strong></p><p>Many of us now try to buy the energy-saving lamp, rent the electric car, and favor the store where they use less packaging. In other words: we choose products with a smaller footprint and we influence our vendors to do the same.</p><p>But when it comes to services online you’ll notice there isn’t much to choose from. No online service claims to be more environmentally friendly than the other. Why is that? It makes sense once you understand that the online services rely on data centers or cloud infrastructure providers, who in turn offer virtually no green options. Many may buy green energy, and there is some improvement in increased cooling efficiency and higher per-machine utilization, but this is largely invisible to the service providers, resulting in the lack of a green alternative available to cloud customers.</p><h3>Solving both these problems at once</h3><p>🤔. What if we move these servers to places where the heat can be re-used? 🌱 And what if we connect all the servers together using fiber-optic networks, to form one big and distributed infrastructure 🕸. Can we then offer capacity on this infrastructure to anyone interested in having a truly green option?</p><p>That’s exactly what we’re doing! Consider the following diagram:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CNFDhaEKQmyJ347b.png" /></figure><p>On the left side of our business, we offer a green, sustainable cloud infrastructure as a service. Customers can run generic workloads for web application hosting, big data &amp; analytics, machine learning, etc. details of which you can find on<a href="https://www.greenedge.cloud/"> our site</a>.</p><p>On the right side of our business, we offer places free heating, produced on-site. We select locations where a large percentage of our energy can be used to substitute other primary energy sources and essentially do a simple trade. We get to use their physical space, they get a lower energy bill.</p><p>At our partner locations, we install our servers, which we hook up to our own network. All these edge sites together then make up our infrastructure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1012/0*dY5q5n5Gc301YbGW.png" /></figure><h3>Why now?</h3><p><strong>The cloud market is ready for this</strong></p><p>In 2013 when I worked at Docker as the project started, web application infrastructure meant starting virtual machines and maintaining them as if they were physical computers. Docker changed all that and revolutionized the way (almost) every company now manages its applications. I should also mention Kubernetes, which is a huge and very popular open-source project. It was initially made possible in large part because of the success of Docker but has since grown to be much bigger and broader. It now brings a whole ecosystem of tools along and has created an universal interface which is compatible between different cloud providers.</p><p>The broad support by cloud providers, and rapidly growing adoption of Kubernetes means customers can now more easily switch between cloud providers, and develop systems where different parts of their application run on different providers’ infrastructure.</p><p>For GreenEdge this is a huge benefit. We are small and the hyperscalers so large that we should be comfortable with customers utilizing both. That’s why we also support Multi-Cloud, where customers run workloads at several clouds at the same time and Hybrid-Cloud, where customers run work on-site and in the cloud.</p><p><strong>The Netherlands is watching its waste</strong></p><p>Throughout society, we see a growing awareness of the upcoming climate problem, and the pressing need to reduce, re-use, and recycle. Amsterdam has called for a stop in the building of new data centers, and the municipality has set itself the ambitious goal to no longer use natural gas for heating by 2040. — It <em>needs</em> alternative sources of heat.</p><h3>Call to Action</h3><p>The problems we are trying to solve are complex and our plan is unique. We would like to invite you to join in, and help us meet our goals. One of the best ways is to start by reaching out and start a conversation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*otET2RZTrMIm0jWu.jpg" /></figure><p><em>Originally published at </em><a href="https://www.greenedge.cloud/blog/its-time-to-do-something-about-dirty-clouds/"><em>https://www.greenedge.cloud</em></a><em> on June 10, 2020.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4728474a4e2f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why choose between gRPC and REST?]]></title>
            <link>https://medium.com/@thatcher/why-choose-between-grpc-and-rest-bc0d351f2f84?source=rss-6bb2705ccda0------2</link>
            <guid isPermaLink="false">https://medium.com/p/bc0d351f2f84</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[rest]]></category>
            <category><![CDATA[grpc]]></category>
            <category><![CDATA[golang]]></category>
            <dc:creator><![CDATA[Thatcher Peskens]]></dc:creator>
            <pubDate>Mon, 26 Feb 2018 14:01:01 GMT</pubDate>
            <atom:updated>2018-02-26T14:42:54.007Z</atom:updated>
            <content:encoded><![CDATA[<h4>Options for letting your service expose both REST and gRPC API’s on a single port.</h4><h3>Summary</h3><p>In this article, I explore the options for making a service, written in Go, expose both a gRPC and REST API on a single port. I explain how one may use the popular <a href="https://github.com/grpc-ecosystem/grpc-gateway">grpc-gateway</a> to auto-generate a REST-full JSON API from gRPC definitions, and then show how to make both API’s use the same port using an HTTP multiplexer. I then conclude there are severe limitations to this approach and show an alternative using CMUX, a TCP multiplexer. This results in a cleaner and better architecture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*dZ0hpt-5g3Bd5ivpwWR9-A.png" /></figure><h3>Introduction</h3><p>I found myself working on an open-source project called <a href="https://github.com/dhrp/moulin">Moulin</a>, a reliable queue for batch processing written in Go and backed by Redis. As there would be different use-cases I want to provide users the choice between a fast gRPC option, and a more traditional REST API. I also want to be able to add a web interface later.</p><p>From the gRPC docs page I read that there exists a “popular project” called <a href="https://github.com/grpc-ecosystem/grpc-gateway">GRPC Gateway</a>. It allows you to annotate your Protobuf definitions, and it will then auto-generate code for the HTML handlers, take care of conversion from JSON to Protobuf and back, and forward it to an upstream gRPC server.</p><p>I decided it would be great if both API’s could share the same port (i.e. 80 or 443). That way in deployment the user may map a single hostname and it would “just work”. The reasoning is that gRPC uses http2, which makes it all HTTP.</p><p>Brendon Philips, from CoreOS has published an article titled “<a href="https://coreos.com/blog/gRPC-protobufs-swagger.html">Take a REST with HTTP/2, Protobufs, and Swagger</a>” where he explains this approach. I originally decided to write an article on this same topic because I felt that the topic of creating and sharing a TLS certificate with this approach had issues and was not well documented. I later found a better solution (for my needs) altogether.</p><h3>How it works:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/1*N9v-iq0uqkE8Hv9k6pbrnQ.png" /></figure><p>Both gRPC and HTTP clients connect to the same port on the application, served by go’s http request multiplexer.</p><p>The multiplexer checks if the http version is http2 and if the content-type is `application/ grpc`.</p><p>If it is, we just pass the request onto the gRPC handler. If it is not we pass the HTTP message to the <a href="https://github.com/grpc-ecosystem/grpc-gateway">gRPC gateway</a>, which then does its magic to make it <em>into</em> a gRPC message, creates a new connection and then forwards it to the gRPC server. Sure, there is a little overhead, but gRPC is fast, and this saves a lot of code (…).</p><p>Here you can find the full source-code:</p><p><a href="https://github.com/dhrp/grpc-rest-go-example">dhrp/grpc-rest-go-example</a></p><p>Here is the function that does the actual discrimination:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dc4c0b2fd450cf662aa68f4b80c9f175/href">https://medium.com/media/dc4c0b2fd450cf662aa68f4b80c9f175/href</a></iframe><p>It was not easy to setup, but it works.</p><blockquote>It also left me unsatisfied…</blockquote><h3>Caveats</h3><p>The thing is that this solution comes with a couple of caveats...</p><p>At first I thought I could get away with disabling TLS for the gRPC server, because while gRPC encourages TLS, it does have a `WithInsecure()` function.. The core of the problem is that we’re using a <em>http</em> multiplexer, and so have to use `grpc.ServeHTTP()` instead of `grpc.Serve()`. This uses go’s http2 libraries under the hood, and they <em>do</em> <a href="https://golang.org/src/net/http/server.go?#L2746">require TLS</a>. <strong>So we’ll have to deal with TLS internally. </strong>This is frustrating. In the illustration above it is the connection between the grpc-gateway and the grpc handlers. You can read more about this issue here: <a href="https://github.com/grpc/grpc-go/issues/555">https://github.com/grpc/grpc-go/issues/555</a></p><p>OK, So.. The (internal) connection between the REST proxy and the gRPC server has to be over TLS, but the gRPC+REST port also needs to be remotely accessible. The real pain is that, therefore, the certificate needs to be issued not for localhost, but some actual hostname or IP. Whenever you deploy, you need to recreate the certificate and you need to configure the proxy internally to use that new address or hostname, otherwise the connection will be refused.</p><p>This is a hassle, and depending on your network setup may also cause a network traffic loop back over your load balancer. If you are developing an internal API or hosted (proprietary) solution, and expect to gain a lot of benefit of not having to recreate the REST endpoints, it may still be worth it. But beware that sharing development efforts may be more difficult. It could then actually be better to keep the classic setup where the grpc-gateway (proxy) is served from a different host.</p><p>In trying to use the gRPC gateway I have also found other limitations, mostly caused by REST not cleanly mapping onto gRPC, the result is that the REST API is kinda’ ugly. For example, you can’t use query parameters, or form-upload a file.</p><h3>Alternatives</h3><p>So, while we have shown (and given code) to make it work, we also recognise it’s not pretty. So what is the alternative?</p><blockquote><em>Don’t use the grpc-gateway</em></blockquote><p>The problem with the internal TLS connection only exists because we are setting up a new gRPC connection after we’ve received a HTTP request.</p><p>If we don’t use the gRPC-gateway we may still use the HTTP multiplexer to send traffic to either gRPC handlers or regular HTTP handlers.</p><h4>Using (only) the HTTP multiplexer</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*qUT2-Po_C_5Tj9L7nwvUzQ.png" /></figure><p>This way, as shown in the illustration, we now still have one open port on which the HTTP request multiplexer listens, but two sets of handlers.</p><p>The HTTP multiplexer checks what type of request it is and forwards it to the appropriate handlers.</p><p>We can then write simple HTTP handler functions that simply call the same business logic as the gRPC calls do.</p><p>A little example for how to do this in code can be found <a href="https://github.com/dhrp/grpc-rest-go-example/blob/master/server/main.go#L112">here</a>.</p><p>Because of the use of http2, TLS is still required on the external http multiplexer port, but this is not a real problem. But if you want, you can work around that, too.</p><h4>Use a TCP multiplexer (cmux)</h4><p>It is also possible to multiplex the connection at the TCP level. There is a great little go library called <a href="https://github.com/soheilhy/cmux">cmux</a> which allows mixing and filtering of different <em>protocols </em>on a single port<em>, </em>not just filtering on different routes or versions of HTTP.</p><p>It works by reading the first couple of bytes from the incoming request to determine which protocol it is. If it is HTTP, it forwards it to the HTTP handlers, if it’s gRPC it forwards it to the gRPC handlers. But it’s not limited to HTTP and gRPC. It could also do SSH, or FTP, or whatever your heart desires. For example both HTTP and HTTPS on the same port. This makes it very flexible.</p><p>In a different branch I have ported the example code I showed first to use this approach, and it works like a charm.</p><p><a href="https://github.com/dhrp/grpc-rest-go-example/tree/nogateway">dhrp/grpc-rest-go-example</a></p><h3>Conclusion</h3><p>After spending time to figure out the details of these different options I believe the GRPC-Gateway is not a great choice for my needs. While it is a cool project and idea, the setup of internal TLS is required and annoying, and in this configuration it may cause unexpected network issues and overhead. The grpc-gateway also has some other limitations that influence the design of your REST API.</p><p>Without it, our application will need to implement the event handlers twice. Once for gRPC and once for HTTP calls. Depending on your application structure, and the amount of endpoints that you have the overhead is limited. In my situation the savings are not worth the trouble. Whether you choose for the HTTP or TCP muxer matters less, but the TCP muxing option gives you the most flexibility and is what we’ll go for, for now.</p><p>Thanks for reading!</p><h3>Acknowledgements / links</h3><ul><li><a href="https://github.com/grpc-ecosystem/grpc-gateway">GRPC Gateway</a>: . This is really what inspired me to explore this option.</li><li><a href="https://www.cockroachlabs.com/blog/a-tale-of-two-ports/">A tale of two ports</a>; CockroachDB was (among the) first to push for the use-case of mixing gRPC and REST on one port in Golang.</li><li><a href="https://coreos.com/blog/grpc-protobufs-swagger.html.">Take a REST with HTTP/2, Protobufs, and Swagger</a>; Who showed how to make it work on one port by Brandon Philips (CoreOS)</li><li><a href="https://blog.dgraph.io/post/cmux/">Golang: Run multiple services on one port</a>; Article by Ashwin Ramesh of Dgraph showing how to use cmux.</li><li><a href="http://Connection multiplexer for GoLang">CMUX, TCP multiplexer for Golang.</a></li><li><a href="https://github.com/grpc/grpc-go/issues/555#issuecomment-321541162">AlesSI</a> for pointing to Cmux on the go-grpc issue.</li><li>And thanks to <a href="https://twitter.com/MarkGituma">Mark Gituma</a> for giving me feedback on the article!</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bc0d351f2f84" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>