


The difference between Mini Program cloud development and non-cloud development
1. Cloud development does not require building a server. Mini Program Cloud provides a free basic version , if it is non-cloud development, you need to build a server.
2. Cloud development projects can be launched quickly, and can be used to add, delete, modify, and query databases and store objects without relying on external cloud servers.
The Pitfalls of WeChat Mini Program Cloud Development
1. The Basic Edition CDN Traffic Is Too Little
In my case In a recent project, during the development and testing period alone, it took 765MB to upload/download the original quality pictures of the album (four to five days). At that time, I realized the seriousness of the matter, because after the project went online It needs to be used by hundreds of users every day. If it is like what I tested, the CDN traffic may be used up in two days. Once the CDN traffic is used up, upgrading the configuration will cost at least 30 yuan a month. At this price, you can buy a good object storage service outside.
But fortunately, I discovered this problem relatively early and controlled the quality of the uploaded pictures in time. The program automatically compresses each picture uploaded. Each picture is about 200kb. It has only been consumed since it was officially used. Received about 1mb of CDN traffic. (The average daily active users are about 60)
2. There are many restrictions on cloud databases
I think this pitfall is the deepest one for me. There are two limitations of cloud databases. The first aspect is the limit on the number of data items obtained by the mini program. The second aspect is cloud database read and write permission restrictions.
(1) Mini program read limit
The mini program directly requests the database, and can read up to 20 pieces of data each time
Use cloud functions to request the database, and then Trigger the cloud function through the applet, and read up to 100 pieces of data each time
If more than 100 pieces of data need to be requested each time, you need to use skip to request in batches and then combine them. The specific operation can be viewed Official documentation or other blogs.
(2) Cloud database read and write permission restrictions
Before talking about this pitfall, let me say that the mini program cloud database is a non-relational database and cannot use joint queries with foreign keys and internal keys. (Irrelevant to the context, not mentioned in this article)
The most open permission of the cloud database is: readable by all users, only the creator can change it.
That is to say, if you create a record, others cannot modify or delete it, which leads to a series of problems. Here is an example of my actual project.
eg: There is a multi-seat study room for users to book. Users can choose a usage time for each reservation. After this time is over, the seat can be booked again by others.
A simple scenario. Under normal logic, the study room table in our database should have these three main fields. Study room identification (r_id), study room expiration time (r_date), Whether the study room can be reserved (r_flag).
When a user chooses to reserve a study room, I only need to determine whether the r_flag of the study room is true. If it is true, the user can reserve it. After the reservation is successful, r_date is refreshed and r_flag is set to false. Can.
However, the most open permissions for the cloud database provided by Mini Program Cloud Development are readable by all users and can only be changed by the creator. As a result, the above logic does not work. We need more complex logic to implement this function.
What I did at the time was: submit a piece of data every time a user makes a reservation for a study room, and put all the reservation data for each study room into stacks in order of time, with the latest reservation on top. In this way, the next time someone makes a reservation, they only need to compare whether the r_date of the top data is reached to determine whether the study room can currently be reserved. Implement an overwrite and delete function without modifying the record.
3. There are many restrictions on opening to the outside world
A normal mini program project will generally be equipped with a backend management system. This backend management system and the mini program share a database to manage data. Since the cloud database that comes with the mini program cloud development is inside the mini program, if the outside wants to access this database, a slightly complicated process is required:
First use the official interface to obtain the calling credentials, and then use the specified credentials through this credentials Interface to add, delete, modify and check the database. In addition, the resources consumed in this process are also included in the basic configuration, and 50,000 requests are made online every day.
Recommended tutorials: "Small Program Development" "PHP Tutorial"
The above is the detailed content of The difference between small program cloud development and non-cloud development. For more information, please follow other related articles on the PHP Chinese website!

随着移动互联网技术和智能手机的普及,微信成为了人们生活中不可或缺的一个应用。而微信小程序则让人们可以在不需要下载安装应用的情况下,直接使用小程序来解决一些简单的需求。本文将介绍如何使用Python来开发微信小程序。一、准备工作在使用Python开发微信小程序之前,需要安装相关的Python库。这里推荐使用wxpy和itchat这两个库。wxpy是一个微信机器

小程序能用react,其使用方法:1、基于“react-reconciler”实现一个渲染器,生成一个DSL;2、创建一个小程序组件,去解析和渲染DSL;3、安装npm,并执行开发者工具中的构建npm;4、在自己的页面中引入包,再利用api即可完成开发。

微信小程序是一种轻量级的应用程序,可以在微信平台上运行,不需要下载安装,方便快捷。Java语言作为一种广泛应用于企业级应用开发的语言,也可以用于微信小程序的开发。在Java语言中,可以使用SpringBoot框架和第三方工具包来开发微信小程序。下面是一个简单的微信小程序开发过程。创建微信小程序首先,需要在微信公众平台上注册一个小程序。注册成功后,可以获取到

实现思路x01服务端的建立首先,在服务端,使用socket进行消息的接受,每接受一个socket的请求,就开启一个新的线程来管理消息的分发与接受,同时,又存在一个handler来管理所有的线程,从而实现对聊天室的各种功能的处理x02客户端的建立客户端的建立就要比服务端简单多了,客户端的作用只是对消息的发送以及接受,以及按照特定的规则去输入特定的字符从而实现不同的功能的使用,因此,在客户端这里,只需要去使用两个线程,一个是专门用于接受消息,一个是专门用于发送消息的至于为什么不用一个呢,那是因为,只

PHP与小程序的地理位置定位与地图显示地理位置定位与地图显示在现代科技中已经成为了必备的功能之一。随着移动设备的普及,人们对于定位和地图显示的需求也越来越高。在开发过程中,PHP和小程序是常见的两种技术选择。本文将为大家介绍PHP与小程序中的地理位置定位与地图显示的实现方法,并附上相应的代码示例。一、PHP中的地理位置定位在PHP中,我们可以使用第三方地理位

本篇文章给大家带来了关于微信小程序的相关问题,其中主要介绍了如何在小程序中用公众号模板消息,下面一起来看一下,希望对大家有帮助。

随着小程序的广泛应用,越来越多的开发者需要将其与后台服务器进行数据交互,其中最常见的业务场景之一就是上传文件。本文将介绍在小程序中实现文件上传的PHP后台实现方法。一、小程序中的文件上传在小程序中实现文件上传,主要依赖于小程序APIwx.uploadFile()。该API接受一个options对象作为参数,其中包含了要上传的文件路径、需要传递的其他数据以及

苏州健康码的小程序叫“苏康码”,它是苏州市疫情防控指挥部指定的通行服务码,疫情防控期间在全市范围内通用,可以作为广大民众日常出行的重要凭证,同时作为防疫人员查验的主要依据;也是省内所有来苏逗苏人员以及在苏工作学习生活,旅游或临时停留人员申报的键康申报数据为基础,结合相关数据比对后动态生成的个人电子健康凭证。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),
