douchao1957 2018-07-20 23:48
浏览 223

是否可以在内部(专用)IIS服务器上运行Golang REST Web应用程序?

I would like to create a web service with GoLang that runs either on IIS (7, 8 or 10) or under Tomcat 7.0. We have multiple environments, each with multiple servers, all being Windows 2008 R2, 2012 or 2016. All servers are private (10.x). My goal is to add some REST services to a COTS product that uses both IIS and Tomcat. I'd prefer to avoid gluing nginx or something else onto either server at the risk of impairing the COTS product or having their tech support people not answer the phone. Again .. the servers are only accessible via corporate VPN and are not public internet-facing.

Which server would offer the easiest path to get something working -- Tomcat or IIS?

  • 写回答

1条回答 默认 最新

  • dongrong8972 2018-07-21 16:53
    关注

    That's not really about Go, but still there exist at least two solutions I can think of:

    • Reverse proxying of HTTP requests.

      1. Write a plain Go server serving requests via HTTP.

        Maybe turn it into a proper Windows service using golang.org/x/sys/windows/svc.

      2. Deploy it.

        If it's to be hosted on the same machine which runs IIS, then it's fine to make it listen on localhost only. Note that it will need a dedicated TCP port to listen on, and you'll need to make it possible for your server to be somehow configurable in this regard.

      3. Set up reverse proxying in your IIS so that it forwards requests coming to whatever (part of an) URL you want to the Go server.
    • Use FastCGI.

      Go supports serving requests over the FastCGI protocol by means of its standard library, and IIS suports FastCGI workers.

      So it's possible to (re-)write your Go server to use FastCGI instead of HTTP and then hook it into IIS via this protocol.

    The pros and cons of these solutions—as I view them—are:

    • Serving over plain HTTP is more familiar to a developer and makes the server more "portable"—in the sense it will be easier to change its deployment scheme if/when you'll need it. Right to making it available to the Internet directly.

      Conversely, with FastCGI, you'll always need a FastCGI host as a "middleware".

    • There were rumors that HTTP code is more fine-tuned in terms of performance than that of FastCGI.

      Still, this only will be of concern for reasonably hard-core loads.

    • One possible upside of FastCGI over HTTP is that it can be served over pipes rather than TCP. For instance, you might get it served over named pipes as it's supported by IIS's FastCGI module and there exists 3rd-party packages for Go implementing support for them (even including one from Microsoft®).

      The upside of this is that pipes are beleived to incur lesser overhead for data transfer (basically it's just shoveling bytes between in-kernel buffers belonging to two processes instead of pushing them through the whole TCP/IP stack), and using pipes frees you from the need of dedicating a TCP port to the Go server.

      Still, I have no personal experience with this kind of setup and its performance trade-offs.

    评论

报告相同问题?

悬赏问题

  • ¥15 BP神经网络控制倒立摆
  • ¥20 要这个数学建模编程的代码 并且能完整允许出来结果 完整的过程和数据的结果
  • ¥15 html5+css和javascript有人可以帮吗?图片要怎么插入代码里面啊
  • ¥30 Unity接入微信SDK 无法开启摄像头
  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算