dousuowu4610
2018-05-07 21:10
浏览 55
已采纳

可以使用API​​代替SDK吗?

I like fast code execution (because of that I switched from Python to Go) and I do not like dependencies. Amazon recommends using SDK for simpler authentication (but in Lambda I can get tokens from IAM from environment variables) and because of built into SDK retry on errors (few lines of code, as I think). Yes it is faster to write my code using SDK, but what additional caveats about using pure HTTP API instead of SDK? Am I too crazy about milliseconds? Such optimizations worth it?

图片转代码服务由CSDN问答提供 功能建议

我喜欢快速执行代码(因为我从Python切换到Go),而且我不喜欢依赖项。 亚马逊建议使用SDK进行更简单的身份验证(但在Lambda中,我可以从环境变量从IAM获取令牌),并且由于SDK内置错误重试功能(我认为代码很少)。 是的,使用SDK编写代码更快,但是关于使用纯HTTP API而非SDK的其他警告? 我对毫秒太疯狂了吗? 这样的优化值得吗?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • doulao3078 2018-05-08 03:20
    已采纳

    I think the stated focus on performance belies real trade-offs.

    Consider that someone will have to maintain your code -- if you use an API, the test area is small, but AWS APIs might change or be deprecated; if you an SDK, next programmer will plug in new SDK version and hope that it works, but if it doesn't they'd be bogged down by sheer weight of the SDK.

    Likewise, imagine someone needs to do a security review of this app, or to introduce something not yet covered by SDK (let's imagine propagating accounting group from caller role to underlying storage).

    I don't think there is a clear answer.

    Here are my suggestions:

    • keep it consistent -- either API or SDK (within given app)
    • consider the bigger picture (how many apps do you plan to write?)
    • don't be afraid to switch to the other approach later

    I've had to decide on something similar in the past, with Docker (much nicer APIs and SDKs/libs). Here's how it played out:

    For testing, we ended up using beta version of Docker Python bindings: prod version was not enough, and bindings (your SDK) were overall pretty good and clear.

    For log scraping, I used HTTP calls (your API), "because performance", in reality comparative mental load using API vs SDK, and because bindings (SDK) did not support asyncio.

    点赞 打赏 评论
  • dsafew1231 2018-05-07 22:01

    Anything you do with AWS is the result of an API call, whether executed by CLI, Web console, or SDK.

    The SDKs make it easier to interact with those APIs. While you may be able to come up with some minor improvements for some calls, overall you will spend a lot of time doing it to very little benefit.

    点赞 打赏 评论

相关推荐 更多相似问题