serverless: Binary Version install is slow in China

Feature Proposal

Description

  1. What is the use case that should be solved. The more detail you describe this in the easier it is to understand for us.

When using Binary version to install serverless, I use curl -o- -L https://slss.io/install | bash command, and it succeeds, while when I want to upgrade to the latest version, it takes a very long time and the connection failed in China. The logs look like this:

安装二进制的 serverless framework 可以成功,但是使用升级命令很慢,卡在了下面的步骤:

$ serverless upgrade
Serverless: Downloading new version...

After that, I want to remove the old binary version and try to install the latest version via npm install, but it failed. When the Framework version is “standalone”, I cannot uninstall nor switch to npm version. Do we have plans to remove standalone serverless framework, or accelerate the upgrade process, and get more detailed outputs?

此外,在升级失败后,我希望切换成npm的方式安装,但是不生效。而且没有办法移除掉二进制的安装包。后续是否会支持类似 remove的命令,删除二进制包呢?或者让升级命令更快一些,输出更多的日志?

$ serverless -v
Framework Core: 1.60.5 (standalone)
Plugin: 3.2.7
SDK: 2.2.1
Components Core: 1.1.2
Components CLI: 1.4.0

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 21 (20 by maintainers)

Most upvoted comments

@tinafangkunding I think we can follow similar check as it’s done in serverless-tencent-tools https://github.com/serverless-tencent/serverless-tencent-tools/blob/3c1cabbdb21c0b3ba37248b9c2f609ec552bf8fc/sdk/others/isInChina.js#L12

So in bash script I will confirm on timezone of a user, if it’s a China timezone we will assume user is in China.

That’s I guess best we can do

@tinafangkunding I think we can improve situation in China, if Tencent on your side prepares some simple API, which we could use to upload binaries directly to China, and then download it from there for Chinese users.

I imagine a possible API endpoints as:

POST /release

Publish a release, where release is e.g. following object:

{
  "version": "1.65.0",
  "tag": "latest",
}

On server side it should create a new release with latest tag and remove that tag from any previous release that had it.

Returns release meta as:

{
  "id": "{releaseId}",
  "version": "1.65.0",
  "tag": "latest",
  "assets": []
}

POST /release/{releaseId}/assets?name=${assetName}

Upload a release asset (binary), where name reflects filename, and is also used to differentiate between OS distributions, e.g. serverless-mac or serverless-win.exe.

Returns asset meta as:

{
  "id": "{assetId}",
  "name": "serverless-mac",
  "url": "https://..."
}

Note: URL to binary must be publicly accessible (installation scripts on developer machines will attempt to download binary from that location)

GET /release/latest

Return metadata of release that’s tagged as latest, where response could be as:

{
  "id": "{releaseId}",
  "version": "1.65.0",
  "tag": "latest",
  "assets": [
    { "id": "{assetId}", "name": "serverless-linux", "url": "https://..." },
    { "id": "{assetId}", "name": "serverless-mac", "url": "https://..." },
    { "id": "{assetId}", "name": "serverless-win.exe", "url": "https://..." }
  ]
}

@tinafangkunding thanks for report.

When using Binary version to install serverless (…) it succeeds, while when I want to upgrade to the latest version, it takes a very long time and the connection failed in China

Technically in both cases binary is downloaded from same url, so it’s wierd that performance of both methods is different for you (do you reproduce it in all cases, or maybe it’s just occasional glitch?)

When the Framework version is “standalone”, I cannot uninstall

You can uninstall standalone with sls uninstall command. Still note that if you had npm installed version, it’ll surface then (so technically sls command may still be available but then it’ll be from global npm installation)

it takes a very long time and the connection failed in China

I think due to nature of China internet, best would be to provide special mirror for China, and rely on it for all installs and upgrades from China, it’s just not that trivial to setup, so it may take some time to have it (please raise it in Slack).