# App upgrade center uni-upgrade-center

# Overview

The app upgrade center uni-upgrade-center provides version update services for apps. include

  • Complete App installation package upgrade for Android and iOS and incremental update of wgt resource package
  • Background management system for releasing new versions and setting upgrade strategies

If an initial release is required, not an upgrade, see also the product uni-portal unified release page

This product has the following features:

  • 开源、免费。uniCloud阿里云版和支付宝云版都有免费空间。

  • Cloud implementation is based on uniCloud. Background management is a plugin of the uni-admin framework.

  • The database follows the specification of opendb

  • About the use of the uni-upgrade- uni-upgrade-center after app transfer Details

从 uni-upgrade-center v0.7.0 版本起,开始支持uni-app x。

为了一套代码同时兼容uni-app和uni-app x,升级中心原本的 js 文件改为了 ts 文件。如果开发者的项目下未使用ts,那么需要增加ts编译。HBuilderX项目会自动加载ts编译器,cli项目则需要自己手动配置。

# Why do I need an upgrade center?

Every App developer has to develop an upgrade function, which is a huge waste of social data. DCloud launched uni-upgrade-center to make application development easier and more efficient, allowing developers to focus on their own business.

升级中心分为两个部分:uni-upgrade-center Admin管理后台uni-upgrade-center-app前台检测更新

# uni-upgrade-center Admin 管理后台

Responsible for releasing new versions and managing the online and offline of historical versions. The following functions are provided:

  • CDN acceleration of cloud storage installation package, making installation package download faster and more stable

  • Application management, information record of App and application version management

  • Version management, you can release a new version, and you can easily and intuitively view, edit and delete the current historical version of the app and the online version

  • Version release information management, including update title, update content, version number, silent update, forced update, and flexible online release settings and modifications

  • Native App installation package, release Apk update, for the whole package update of App, can set whether to force the update

  • wgt 资源包,发布 wgt 更新,用于 App 的热更新,可设置是否强制更新,静默更新(uni-app x的app-Android由于编译为纯原生,没有wgt包,无法热更新)

  • App management list and App version record list search

# 使用教程

新建 uni-admin 项目

  1. 新建项目:打开HBuilderX -> 文件 -> 新建 -> 项目 -> uni-app 选择 uniCloud admin模板,键入一个名字,确定

  2. 鼠标右键 uniCloud 文件夹 选择关联云服务空间运行云服务空间初始化向导

Add App

运行 uni-admin 到浏览器,在左侧菜单 系统管理 -> 应用管理 中新增应用后,即可在 App升级中心 发布该应用的版本 详情

添加应用后,即可在应用管理列表中跳转至版本管理页面:

Version management

  1. 在版本管理列表页面右上角点击发布新版,可以发布原生App安装包wgt资源包。在左上角点击下拉列表,可以切换展示应用。
  • Publish native App installation package

    1. Fill in the release information on the upload installation package interface
    1. 版本号:请填写以.分隔字符串,例如:0.0.1。在构建应用安装包时,manifest.json 中的 应用版本名称 也要是该格式。

    2. Android应用市场

      • It will be synchronized with the Android App Market information filled in when Adding an app. When the application information is modified in the application management, it will also be modified here
      • Enable store: When a store is checked to enable, it will detect whether the app market exists on the phone on the upgrade-center-app side
        • If there is, it will jump to the app store to upgrade the app
        • If the jump fails, the download link will be used to download the apk installation package and upgrade
      • Priority: When checking for updates, try to jump to the store in descending order of priority
    3. 下载链接/AppStore

      • You can choose to manually upload a file to cloud storage, and the address will be automatically filled in this item
      • 也可以手动填写一个地址,就可以不用再上传文件
      • 如果是发布 苹果 版本,包地址则为应用的 AppStore 链接
    4. 强制更新

      • 如果使用强制更新,App端的升级弹框将不可被关闭
    5. 上线发行

      • You can set whether the current package is released online or not, and the update detection will only be performed if it is online
      • There can only be one online distribution at the same time, and online distribution cannot be changed to offline. Not online can be set as online release and automatically replace the current online release
      • Modify the current package to be released online, and automatically replace the current online release
  • Publish wgt resource pack

    1. Most of the configuration is consistent with the release of the native App installation package
    1. 原生App最低版本

      • 上次使用新api或打包新模块的pp版本
      • 如果此次打包的wgt使用了 新的 api 或者打包了 新的模块 ,则在发布 wgt资源包 的时候,要将 原生App最低版本 填写为本次版本
      • 如果已有正式版 wgt资源包 ,则会自动带出
    2. Silent Update

      • When the app is upgraded, the wgt package will be downloaded in the background and installed by itself. The new function takes effect the next time the app is launched
      • **Do not restart the app after silent update, which may cause the page data of the app you are visiting to be confused, please use it with caution! **
  • Post completion page

  • uni-upgrade-center 云函数 - 检查应用更新:

    • 根据传参,先检测传参是否完整,appid appVersion wgtVersion 必传,is_uniapp_x 选传,默认 false

    • 先从数据库取出所有该平台(会从上下文读取平台信息)的所有线上发行更新

    • 再从所有线上发行更新中取出版本最大的一版。如果可以,尽量先检测wgt的线上发行版更新

    • 使用上一步取出的版本包的版本号 和传参 appVersion、wgtVersion 来检测是否有更新。必须同时大于这两项,因为上一次可能是wgt热更新,否则返回暂无更新

    • 如果库中 wgt包 版本大于传参 appVersion,但是不满足 min_uni_version < appVersion,则不会使用wgt更新,会接着判断库中 app包version 是否大于 appVersion

    • 返回结果:

      code message
      0 当前版本已经是最新的,不需要更新
      101 wgt更新
      102 整包更新
      -101 暂无更新或检查appid是否填写正确
      -102 请检查传参是否填写正确

Tips

  • /uni_modules/uni-upgrade-center/pages/version/add.vue中有版本对比函数(compare)。
    • Use multipart version format (eg: "3.0.0.0.0.1.0.1", "3.0.0.0.0.1"). If it does not meet the comparison rules, please modify it yourself.
  • 删除应用会把该应用的所有版本记录同时删除
  • iOS的Appstore是禁止热更新的。本产品的iOS热更新功能,主要是为企业用户设计的。如果您在Appstore公开市场使用热更新,需要自己承担政策风险。
  • wgt updates for iOS can be supported with the following modifications:

    \uni_modules\uni-upgrade-center\pages\mixin\version_add_detail_mixin.js

    Set the enableiOSWgt property in data to true

# uni-upgrade-center-app 前台检测更新

除了管理端,升级中心还包括客户端。负责前台检查升级更新,弹出提示框,下载和安装新版。

官方升级弹框样式 升级支持多商店 使用uni.showModal自定义弹框

The following functions are provided:

  • 基于uni-upgrade-center一站式检查更新,统一整包与 wgt 资源包更新

  • Complete the verification according to the parameters passed by yourself, and determine which method to use for this update

  • 弹框、下载、安装、是否强制重启等逻辑已集成

  • 下载完成如被用户取消升级,自动缓存安装包,下次进入判断是否符合安装条件,判断通过会复用已下载的包进行安装;判断不通过则自动清除(uni-app x 的 app-Android 端暂不支持安装包缓存功能:下载到临时保存目录,在 App 下次启动时自动清除)

  • 弹框美观,可自定义ui

# 目录结构

	
┌─uniCloud                            云空间目录,在 uni-upgrade-center-app 组件中为空,占位使用
│─components                          符合 easycom 组件规范的组件目录
│  └─uni-upgrade-center-app
│     └─uni-upgrade-center-app.uvue   uni-app x 项目中要使用到的升级中心弹窗组件,如果需要自定义弹窗样式,可以修改此组件
├─pages                               页面文件存放的目录
│  └─upgrade-popup.vue                uni-app 项目中要使用到的升级中心页面,如果需要自定义样式,可以修改此页面
├─static                              存放升级中心引用的静态资源(图片)的目录,如需自定义样式,可以替换此目录下的图片
├─utils                               存放升级中心引用的工具函数的目录
│  ├─call-check-version.ts            升级中心请求云端函数方法,调用 uni-upgrade-center 云函数,获取 App 版本信息
│  ├─check-update.ts                  调用升级中心方法,检查更新,并根据结果判断是否显示更新弹框
│  └─utils.uts                        uni-app x 项目中要使用到到工具函数,openSchema 为打开应用外部链接方法
├─changelog.md                        uni-upgrade-center-app 更新日志
├─package.json                        uni-upgrade-center-app 插件信息日志
└─readme.md                           uni-upgrade-center-app 说明文档
	
  • upgrade-popup.vue - 更新应用:
    • 如果云函数uni-upgrade-center返回的参数表明需要更新,则将参数保存在localStorage中,带着键值跳转该页面
    • 进入时会先从localStorage中尝试取出之前存的安装包路径(此包不会是强制安装类型的包)
    • 如果有已经保存的包,则和传进来的 version 进行比较,如果相等则安装。大于和小于都不进行安装,因为admin端可能会调整包的版本。不符合更新会将此包删除
    • 如果本地没有包或者包不符合安装条件,则进行下载安装包
    • 点击下载会有进度条、已下载大小和下载包的大小
    • 下载完成会提示安装:
      • 如果是 wgt 包,安装时则会提示 正在安装…… 和 安装完成。安装完成会提示是否重启
      • 如果是 原生安装包,则直接跳出去覆盖安装
    • 下载过程中,如果退出会提示是否取消下载。如果是强制更新,则只会提示正在下载请稍后,此时不可退出
    • 如果是下载完成了没有安装就退出,则会将下载完成的包保存在本地。将包的本地路径和包version保存在localStorage中

# 在 uni-app 中使用升级中心

Installation Guide

  1. 在插件市场打开本插件页面,在右侧点击使用 HBuilderX 导入插件,选择要导入的项目点击确定 插件地址

  2. 创建 uniCloud 云开发环境

  3. 绑定服务空间:

    • Plugin version >= 0.6.0, depends on uni-upgrade-center cloud function of uni-admin 1.9.3+, please associate the same service space with the uni-admin project
    • Plugin version <= 0.6.0, please bind to an existing service space or create a new service space for binding
  4. 上传云函数:

    • The plug-in version >= 0.6.0, depends on the uni-upgrade-center cloud function of uni-admin 1.9.3+, the plug-in no longer provides cloud functions separately, you can skip this step
    • Plugin version <= 0.6.0, find /uni_modules/uni-upgrade-center-app/uniCloud/cloudfunctions/check-version, right click to upload and deploy
  5. 如果是uni-app,需在pages.json中添加页面路径。注:请不要设置为pages.json中第一项。(在 uni-app 上,为了盖住 tabbar、导航栏以及 vue 页面上的原生元素,使用了背景透明的独立页面)

    "pages": [
    		// ...other page configuration
    		{
    			"path": "uni_modules/uni-upgrade-center-app/pages/upgrade-popup",
    			"style": {
    				"disableScroll": true,
    				"app-plus": {
    					"backgroundColorTop": "transparent",
    					"background": "transparent",
    					"titleNView": false,
    					"scrollIndicator": false,
    					"popGesture": "none",
    					"animationType": "fade-in",
    					"animationDuration": 200
    
    				}
    			}
    		}
    	]
    
  6. @/uni_modules/uni-upgrade-center-app/utils/check-update 使用 import 导入到需要用到的地方调用一下即可(一般在首页调用或设置页面检查更新按钮调用):

    1. 使用方式:import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update',然后在需要的执行的地方调用 checkUpdate 方法即可
    2. 默认使用当前绑定的服务空间,如果要请求其他服务空间,可以使用其他服务空间的 callFunction详情
    3. 注: uni-app 的 vue2 模式不支持在 nvue 页面中使用 ts,请引入用插件根目录 utils/check-update-nvue.js 文件
  7. 升级弹框可自行编写,也可以使用uni.showModal,或使用现有的升级弹框样式,如果不满足UI需求请自行替换 static 目录下的资源文件。在utils/check-update.ts中都有实例。

注意 使用wgt更新,打包前请务必将 manifest.json 中的版本名称修改为更高版本。(请使用类似 1.0.0 以 . 分隔的多段式格式)

# 在 uni-app x 中使用升级中心 0.7.0+

安装指引

  1. 在插件市场打开本插件页面,在右侧点击使用 HBuilderX 导入插件,选择要导入的项目点击确定 插件地址

  2. 创建 uniCloud 云开发环境

  3. 绑定服务空间:

    • 插件版本 >= 0.6.0,依赖 uni-admin 1.9.3+uni-upgrade-center 云函数,请和 uni-admin 项目关联同一个服务空间
    • 插件版本 <= 0.6.0,请绑定到一个已有的服务空间或者新建一个服务空间进行绑定
  4. 上传云函数:

    • 插件版本 >= 0.6.0,依赖 uni-admin 1.9.3+uni-upgrade-center 云函数,插件不再单独提供云函数,可以跳过此步骤
    • 插件版本 <= 0.6.0,找到/uni_modules/uni-upgrade-center-app/uniCloud/cloudfunctions/check-version,右键上传部署
  5. 升级中心在 uni-app x 端是 easycom 组件 可直接使用,无需在页面导入注册。在需要显示升级弹窗的页面直接使用组件即可(升级中心弹出时会调用 api 隐藏 tabbar,在关闭时会调用调用 api 显示 tabbar)

    注意组件的 ref 属性

    <!-- 该组件的 @close 方法,会在关闭弹窗的时候调用 -->
    <uni-upgrade-center-app ref="upgradePopup" @close="upgradePopupClose" />
    
  6. script 标签内顶部引入 checkVersion 方法

    import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update'
    
  7. 在需要调用的 页面 中(一般在首页加载完成后调用或设置页面检查更新按钮调用)执行 checkUpdate 方法,比如在 onReady 生命周期中( 注: 因为是组件所以一定要保证组件加载完毕),以下为完整使用示例:

    <template>
    	<view>
    		<!-- 页面其他内容 -->
    		<uni-upgrade-center-app ref="upgradePopup" @close="upgradePopupClose" />
    	</view>
    </template>
    <script>
    	import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update'
    	// ...
    	export default {
    		// ...
    		onReady() {
    			// 此处的 UniUpgradeCenterAppComponentPublicInstance 类型是 easycom 组件使用约定,详见:https://uniapp.dcloud.net.cn/uni-app-x/component/#method-easycom
    			// 此处的 'upgradePopup' 要和组件的 ref 属性一致
    			checkUpdate(this.$refs['upgradePopup'] as UniUpgradeCenterAppComponentPublicInstance)
    		}
    		// ...
    	}
    </script>
    
  8. 当你打开调用升级中心组件的页面就会检查更新,如有更新就出弹窗。也可以在其他页面或者组件中使用

注意 在 uni-app x 的 app-Android 端没有 wgt 更新,也不会检测到 wgt 包的更新

更新下载安装check-update.ts

This function is in the utils directory

  1. 如果是静默更新(wgt 更新特有),则不会打开更新弹框,只在后台下载后安装,下次启动应用生效

  2. If it is iOS, it will directly open the link of AppStore

  3. 其他情况:

    • uni-app:会将检查更新云函数返回的结果保存在localStorage中,并跳转进入upgrade-popup.vue打开更新弹框
    • uni-app x:会将检查更新云函数返回的结果传递给 \uni_modules\uni-upgrade-center-app\components\uni-upgrade-center-app\uni-upgrade-center-app.uvue 组件的 show 方法,修改组件的显示状态,显示更新弹框

Tips

  1. Check and update the version comparison function (compare) inside the cloud function.
    • Use the multi-segment version format (eg: "3.0.0.0.0.1.0.1", "3.0.0.0.0.1"). If you do not meet the comparison rules, please modify it yourself.
    • If modified, please modify the compare function in pages/upgrade-popup.vue together

# Fee Evaluation

使用升级中心,涉及uniCloud的付费问题,那么相比于自己搭服务器,使用uniCloud的费用到底合不合适。这里帮开发者算下账。

以阿里云按量计费为例,预测下uni-upgrade-center在不同用户规模下的资源消耗及对应费用,帮助大家明智选择。

This article is mainly divided into three parts:

  • Calculation of resource costs consumed by uni-upgrade-center (calculated separately for cloud functions, cloud databases, cloud storage, and front-end web hosting)
  • Benefits of uni-upgrade-center for you
  • Comprehensive consideration, how should you choose

The cost involved in uni-upgrade-centeruni-upgrade-center is mainly divided into:

  • Cloud function: uni-upgrade-center cloud function, compare the client version with the latest version of the server, and return the logic of whether to upgrade
  • Cloud database: opendb-app-versions table, storing version information
  • Cloud storage: place recent upgrade package resources (apk/ipa/wgt)
  • Front-end website hosting: deploy uni-admin, the administrator releases a new version

Next, we conduct cost assessments for different resources.

# Cloud Functions

After enabling the uni-upgrade-centeruni-upgrade-center, every time your app starts, it will request the uni-upgrade-center cloud function once.

According to the pay-as-you-go rules listed on the uniCloud official website, we can get the following cloud function resource consumption calculation formula:

Cloud function cost = resource usage * 0.000110592 + number of calls * 0.0133 / 10000 + outbound traffic * 0.8

in:

  • Resource usage = cloud function memory (in G) * average execution time of a cloud function (in seconds) * number of calls
  • Number of invocations = daily activity of the app * the average number of times the daily active user starts the app every day, because every time the app is started, the logic of checking and updating will be executed

We assume the following data model:

  • Cloud function memory: 256M, which is 0.25G; note that the cloud function memory is 512M by default, and the uni-upgrade-center cloud function is recommended to be set to 256M
  • The average execution time of a cloud function: 100 milliseconds, or 0.1 seconds
  • The average number of app launches per day by daily active users: 2 times
  • Outgoing network traffic: 0, the uni-upgrade-center does not need to link to the external network

According to the above formula, if your app has 100 daily active users, the daily fee for the uni-upgrade-center cloud function is:

云函数费用(天) = 资源使用量 * 0.000110592  + 调用次数 * 0.0133 / 10000 + 出网流量 * 0.8
			  = 云函数内存(单位为G) * 云函数平均单次执行时长(单位为秒) * 调用次数 + 调用次数 * 0.0133 / 10000 + 出网流量 * 0.8
			  = 0.25G * 0.1S * 100 * 2 * 0.000110592 + 100 * 2 * 0.0133/10000 + 0
			  = 0.00081896(元)

That is: your App DAU is 100, and after using uni-upgrade-center commercial version, the corresponding cloud function consumes about 0.00081896 yuan per day.

According to this, the monthly cost can be calculated as: 0.00081896 * 30 = 0.0245688, that is, only 2 cents per month;

In the same way, we can deduce that for apps with 1,000, 10,000, and 100,000 DAU, the monthly cost of the uni-upgrade-center cloud function is as follows:

daily activity resource usage billing (yuan) call times billing (yuan) outbound traffic billing (yuan) total (yuan)
100 0.0165888 0.00798 0 0.0245688
1000 0.165888 0.0798 0 0.245688
10000 1.65888 0.798 0 2.45688
100000 16.5888 7.98 0 24.5688

For an app with a daily activity of 1,000, the monthly consumption of cloud functions is only 25 cents (0.25 yuan), which is really drizzle.

# Cloud Database

According to uniCloud official website, cloud database fee = `capacity fee + read operation fee + write operation fee', where :

  • Capacity fee: database storage capacity (in G) * 0.07
  • Fee for the number of read operations: number of read operations (10,000 times) * 0.015
  • Number of write operations: number of write operations (thousands) * 0.015;
# Capacity Fee

Let's take hello uni-app as an example, the opendb-app-versions data table stores a total of 30 upgrade records, with a capacity of 8K. According to this, the daily storage cost of the opendb-app-versions table can be calculated as: 8/1024/1024 * 0.07 = 0.000000534

The billing unit for capacity is G, so it is necessary to convert 8K into M first, and then into G, so the above formula excludes two consecutive 1024

Calculated as 30 days in January, the monthly storage fee is 0.000000534 * 30 = 0.000016, which is less than 1 cent and can be ignored.

Note: The database capacity is only related to the number of released versions, and has nothing to do with daily active users.

# Number of read operations

In the uni uni-upgrade-center business, each time the cloud function uni-upgrade-center is executed, only one database read is called (read the opendb-app-versions table once), so the number of database read operations is equal to the cloud function There is a formula for the number of calls in the previous article, the number of cloud function calls = app daily activity * the average number of times the daily active user starts the app per day, and the average number of times the daily active user starts the app per day is assumed to be 2 times.

We can calculate that if the daily activity of an app is 100, the daily cloud database read operation cost of the uni uni-upgrade-center is calculated as follows:

读操作次数费用 = 读操作次数(万次) * 0.015
			= 云函数调用次数(万次) * 0.015
			= App日活 * 每日活用户平均每天启动App次数 / 10000 * 0.015
			= 100 * 2 / 10000 * 0.015
			= 0.0003

Calculated as 30 days in January, the monthly cloud database read operation fee is 0.0003 * 30 = 0.009, which is less than 1 cent.

In the same way, we can deduce that for apps with 1,000 or 10,000 DAU, the uni uni-upgrade-center will cost 9 cents or 9 cents per month for the number of cloud database read operations.

# Number of write operations

The uni-upgrade-centeruni-upgrade-center has very few database write operations; the administrator only inserts a new version information into the opendb-app-versions table through uni-admin every time a new version is released; the client App Every time you start to check and upgrade, there is no need to write the data table, so the number of write operations can be ignored as 0;

# Summary

Because both the capacity fee and the number of write operations can be ignored as 0, according to the formula:

云数据库费用 = 容量费(忽略为0) + 读操作费用 + 写操作费用(忽略为0)
		   = 读操作费用

It can be deduced that the cloud database billing of the uni uni-upgrade-center is mainly billing for the number of read operations, so we further draw the following predictions:

Daily Activity Capacity Fee (Yuan) Read Operation Fee (Yuan) Write Operation Fee (Yuan) Total (Yuan)
100 0 0.009 0 0.009
1000 0 0.09 0 0.09
10000 0 0.9 0 0.9
100000 0 9 0 9

# Cloud Storage

According to uniCloud official website, cloud storage fee = capacity fee + download operation times billing point + upload operation times billing points + CDN traffic fee.

If your app is uploaded to the Apple store or Android app stores every time, and downloaded and installed from the app store when upgrading, the cloud storage fee will be 0, because the storage and CDN download traffic of the app store are used, and this billing point is evaluated Chapters can be skipped directly.

uni-upgrade-center supports setting the download address of the new version of the application installation package as the address of the application store, so that the storage and CDN of the application store can be used without consuming cloud storage resources of uniCloud.

At this stage, all iOS platforms need to be put on the Apple store, and we can ignore the cloud storage consumption of the iOS platform.

If your Android apk installation package and wgt differential upgrade package are all hosted in uniCloud cloud storage, we can also calculate this account.

# Capacity Fee

The capacity fee is mainly a storage fee, and we can periodically delete expired versions to save capacity fees.

Suppose we keep the latest 5 versions of files in cloud storage, all apk/wgt are kept, and the sizes are assumed to be: 40M and 10M respectively.

As mentioned before, ipa needs to be put on the apple store, and cloud storage is not used, so the evaluation can be ignored.

Then the daily capacity fee is: 5 * (40+10)/1024 * 0.0043 = 0.0010498

According to this, the capacity fee for 30 days per month can be calculated as: 0.0010498 * 30 = 0.031494, that is, only 3 cents;

Note: The cloud storage capacity is only related to the number of historical upgrade packages retained, and has nothing to do with daily active users.

# Billing points for the number of download operations

Billing point for the number of download operations: it will only be triggered when the file download is triggered, and will not be triggered if there is no new version downloaded.

Assume that your app has 100 daily active users and 1500 monthly active users, and a version is released every month; 50% of the monthly active users will choose to upgrade to the new version. We can calculate the number of downloads as: 1500*50% = 750 times.

The billing rule for the number of download operations of cloud storage is: 0.01 yuan per 10,000 times, that is, 1 cent for every 10,000 downloads, and 750 downloads are far less than 1 cent, so the charging point for download operations can be directly ignored.

# Billing points for the number of upload operations

Every time the app is released, the administrator only needs to upload a new resource package once. When the user checks and upgrades on the app side, no upload operation is involved, so the charging point for the number of upload operations can also be ignored.

# CDN traffic fee

CDN traffic fee: We assume a 50% probability of enabling the wgt resource package upgrade (the upgrade package is 10M), and a 50% probability of upgrading the whole package; and in the whole package upgrade, 20% are Apple users (using apple store traffic), and 80% are Android users (the upgrade package is 40M).

According to the above data model, an app with a daily activity of 100 will have a monthly activity of 1500 during holidays, and 50% of the monthly active users will choose to upgrade to the new version, that is, 750 people will choose to upgrade. The CDN traffic consumed by different upgrade packages is as follows:

  • CDN traffic of wgt resource pack: 750 * 50% * 10 / 1024 = 3.662G
  • Apple package upgrade CDN traffic: use apple store traffic, uniCloud cloud storage traffic is 0
  • CDN traffic for Android package upgrade: 750 * 50% * 80% * 40 /1024 = 11.719G

That is: for an app with 100 daily active users, the monthly CDN traffic is: 3.662 + 0 + 11.719 = 15.381G, and the corresponding fee is: 15.381 * 0.18 = 2.76858 (yuan)

In the same way, we can deduce that for an App with 1000 DAU, the monthly CDN fee for its uni-upgrade-center cloud storage is 27.6858 yuan.

# Comparison with traditional OSS + CDN

If you don’t use uni-upgrade-center, choose Alibaba Cloud’s traditional OSS + CDN solution. In the same case of billing according to volume, traditional CDNs have no price advantage within 1PB of traffic; traditional CDNs start at a GB The price is 0.24 yuan, while the cost per GB of uniCloud cloud storage CDN is 0.18 yuan.

For details, see: Alibaba Cloud official website CDN pricing details

What is the concept of 1PB traffic? Let's take each Android installation package as an example of 40M, which requires 1 * 1024 * 1024 * 1024 / 40 = 26843546, that is, 26 million downloads of the installation package are required to achieve 1PB traffic, you can evaluate when your App will be ready reach this level.

Explain in detail: 1PB = 1024TB, 1TB = 1024G, 1G = 1024M, so the above formula is multiplied by 3 1024

Some people also said that buying Alibaba Cloud CDN resource packages can be cheaper. It is true that it is cheaper to buy large resource packs, but this solution has two disadvantages:

  • This resource package is only a CDN traffic package. You also need to purchase an OSS back-to-source traffic package, and uniCloud directly includes the back-to-source traffic fee in the CDN fee, and there is no need to purchase additional back-to-source traffic.
  • Prepayment, when the business development is uncertain, too much money is invested at one time; once the business fails, the CDN resource package is not consumed, and refunds cannot be made, which is a waste of money; while billing by volume does not have this problem, it is true How much resources are used, how much money is spent;

On the whole, uniCloud cloud storage compared with the OSS + CDN solution of traditional cloud vendors:

  • Both choose pay-as-you-go, and the uniCloud version CDN defaults to 0.18 yuan, which has a price advantage;
  • The prepaid method, if you purchase a CDN resource package from a cloud vendor, you need to purchase an additional back-to-source traffic package, which is not friendly to ordinary developers, especially small and medium-sized developers. cost-effective.

# Front-end web hosting

uni-upgrade-center needs to be used in conjunction with uni-admin, and uni-admin needs to be deployed in the front-end web hosting. uni-admin is mainly used by administrators, with less frequent use and lower traffic.

According to uniCloud official website, the front-end web hosting fee = capacity fee + traffic fee.

# Capacity Fee

uni-admin is compiled to 4.7M. According to the rule of 0.0043 yuan per GB per day on the official website, the monthly capacity fee of uni-admin is: 4.7 / 1024 * 0.0043 * 30 = 0.00059, which is less than 1 cent. Ignorable.

# traffic fee

The administrator logs in to uni-admin, browses and publishes new versions on the management page of the uni-upgrade-center, and the traffic required does not exceed 3M. Even if updates are released twice a month, the estimated traffic fee is: 3 / 1024 * 0.18 * 2 = 0.00105, less than 1 cent, can also be ignored.

# Combine calculation

After comparing the details, let’s take a look at how much it costs to use the uniCloud uni-upgrade-center. Compared with the traditional self-developed upgrade logic and building an uni-upgrade-center, where do you need to spend money? What are the differences?

Whether it is the upgrade solution developed by the developer or uni-upgrade-center, the cost of storage + CDN is required. The previous article also compared the cost performance of traditional OSS+CDN and uniCloud cloud storage, all according to In the mode of volume billing, uniCloud is more cost-effective; in the traditional CDN mode of purchasing resource packages, each has its own advantages and disadvantages.

Since the two solutions cannot bypass cloud storage, let's put aside the comparison of cloud storage for the time being, and list other items according to the number of daily active users to see the cost of uni-upgrade-center in other dimensions.

daily activity cloud function (yuan) cloud database (yuan) cloud storage (yuan) front-end web hosting (yuan) total (yuan)
100 0.0245688 0.009 ignore 0 0.0335688
1000 0.245688 0.09 ignore 0 0.335688
10000 2.45688 0.9 Ignored 0 3.35688
100000 24.5688 9 Ignored 0 33.5688

# uni-upgrade-center benefits for you

Use uni-upgrade-center, free access, one-click installation, you will get:

  • Complete inspection and upgrade logic that has been verified by a large number of apps, and supports whole package/resource package upgrades, silent upgrades, and forced upgrades;
  • Complete management functions, release new version by platform, offline old version, associate application store, release by channel, etc.
  • The code is open source and can be customized at will

For the above functions, if you use the traditional model for self-development, you need to cooperate with the front-end and back-end for development. The back-end uses php/java as the interface, the front-end initiates Ajax requests, handles various responses and error codes from the server, and handles upgrade pop-up reminders. These functions do Perfection takes at least 4 working days.

Assuming that the monthly salary of an engineer is 18K, and the comprehensive management costs such as social security are 1.4 times the salary, the comprehensive cost of 4 working days is: 18*1000*1.4/22 * 4 = 4582 yuan.

# Summarize

Let’s talk about uni-upgrade-center again. Compared with the traditional self-developed uni-upgrade-center, the money for storage + CDN will be spent, so we ignore it.

Other cloud functions, cloud databases, etc. seem to be additional costs, but in fact, if you use the traditional php/java self-developed upgrade logic, in addition to self-developed labor costs, the later stage will also consume CPU, memory, and bandwidth resources. These costs are incorporated into the overall rental cost of the virtual machine, and you cannot separate them out for calculation.

Looking back at the calculation table just now, for 1,000 daily active users, the monthly increase of cloud functions and cloud databases is only 0.34 yuan, and the annual increase is only 4 yuan (not considering the cloud storage CDN), which costs more than one year 4 yuan, you can save more than 4,500 yuan in labor costs for self-development, and allow engineers to devote more energy to their core business. Isn't it a good deal for this 5 yuan deal? Isn't it fragrant?

daily activity cloud function (yuan) cloud database (yuan) cloud storage (yuan) front-end web hosting (yuan) total (yuan)
100 0.0245688 0.009 ignore 0 0.0335688
1000 0.245688 0.09 ignore 0 0.335688
10000 2.45688 0.9 Ignored 0 3.35688
100000 24.5688 9 Ignored 0 33.5688

It should be the pursuit of smart engineers not to repeat manufacturing wheels, focus on business, quickly verify models, and achieve business growth.