dongqing7789 2019-08-29 19:28
浏览 159

在Go中使用HTTP与使用TCP套接字将文件下载/上传到服务器有什么优势? [关闭]

I am setting up multiple servers for a social networking app and have never worked with HTTP before. Is there advantages of using HTTP instead of creating your own protocol for TCP streams? It will be used for both normal text transfer and images/videos.

I have started up a general TCP server that can transfer both small organized text packets and also larger image/video streams but I'm unsure if it will be as scalable/efficient/secure as using HTTP/s. I'm not going to post the code as I hope this question is general enough to not require it and I am not looking for code analysis quite yet.

The server is working for transferring data but I am not sure of the advantages/disadvantages of using HTTP instead. Do other websites that use Go for their system use HTTP or just straight sockets?

  • 写回答

1条回答 默认 最新

  • dq804806 2019-08-29 19:36
    关注

    Raw TCP sockets are theoretically more performant (ignoring several external factors) than HTTP.

    HTTP libraries are robust and well tested, and constantly updated in the face of new bugs and security threats.

    So do you optimize for raw performance, or for developer time?

    A few questions to ask yourself:

    1. Is HTTP too slow for my application? (Related question: Have I measured it?)
    2. Do I have the time and energy to respond to bugs and vulnerabilities in my connectivity library for the life of my program?
    3. If I am wildly successful, can I find, hire, train and retain a qualified workforce?

    If this is just for your learning, go for it.

    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘