APP做用户排队功能,是拉取还是推送?
APP功能概述:用户打开APP有一个领取排队号的功能,领取到号后进入等待,等待的过程会显示你排到第几名,大概等待多久,用户会实时的看到排队的信息变化。有点像去银行排队办业务。
遇到的问题:我目前采用的是APP通过定时轮询请求服务端接口,如果APP突然断网,就会卡住队伍,后面的人排不到前面来。我这边写了一个计划任务在后台清理这些异常的用户,个人感觉不是十分理想,请教各位大牛,如果采取推送的方式是否比客户端轮询更有优势?(排队的人数肯定不会超过1000),如果采用推送是用计划任务还是通过某个用户服务完毕或刚加入队伍的用户进行触发推送,或者说有没有其他的方式?
目前还有一种情况就是如果采用APP轮询请求接口,一旦APP进入后台,也就是按了home键之类的,就不会继续请求我的接口,也会被后台程序认为是异常用户清除掉了。
回复内容:
APP功能概述:用户打开APP有一个领取排队号的功能,领取到号后进入等待,等待的过程会显示你排到第几名,大概等待多久,用户会实时的看到排队的信息变化。有点像去银行排队办业务。
遇到的问题:我目前采用的是APP通过定时轮询请求服务端接口,如果APP突然断网,就会卡住队伍,后面的人排不到前面来。我这边写了一个计划任务在后台清理这些异常的用户,个人感觉不是十分理想,请教各位大牛,如果采取推送的方式是否比客户端轮询更有优势?(排队的人数肯定不会超过1000),如果采用推送是用计划任务还是通过某个用户服务完毕或刚加入队伍的用户进行触发推送,或者说有没有其他的方式?
目前还有一种情况就是如果采用APP轮询请求接口,一旦APP进入后台,也就是按了home键之类的,就不会继续请求我的接口,也会被后台程序认为是异常用户清除掉了。
我个人觉得是这样哈,看你业务需求里客户对即时性要求高不高;如果像滴滴打车那样,要一直看见变化的,可以轮询+推送;如果要求不高,可以只推送。感觉推送比轮询重要哈。
主要是不知道这个用户的排队策略;如果是他一进入后台,就视为自动放弃,那么轮询还可以;否则的话,等排到他了他不知道,你把他清掉了,这属于正确性的问题呀~ 还不是系统设计的问题。
我个人觉得一个常见的排队策略是,客户端发一个请求排到队列后面;轮到一个用户,发个推送给他,要求他确认;如果超时不确认,就轮到下一个人。如果用户需要能实时看见排队情况,就加个轮询定时更新;否则就手动更新或者进入界面的时候更新一下就行了。
不知道你们的业务需求是什么~ 系统设计应该贴合业务需求哈。
对即时性要求较高的话,可以采用轮询+推送的方式,优化轮询的方案可以采用'WebSocket'。
如果上面的方式还不能满足需求,建议采用'Socket'通知客户端刷新。
无论是'WebSocket'还是'Socket',都只完成通知刷新的任务,获取数据的方式还是保持Http方式,这样可以在现有基础上降低开发量。
建议推送,轮询太耗服务器资源!
轮询+推送 吧~
推送估计你是用第三方的吧?所以不能太依赖第三方推送。android那么多机子,推送进程被杀毒软件什么的杀死,就扑街了....

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

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

The Redmi Note 14 Pro Plus is now official as a direct successor to last year'sRedmi Note 13 Pro Plus(curr. $375 on Amazon). As expected, the Redmi Note 14 Pro Plus heads up the Redmi Note 14 series alongside theRedmi Note 14and Redmi Note 14 Pro. Li

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

Historically, Oppo has refreshed its flagship 'Find X' series in late winter or early spring, save for the original Find X that it announced in June 2018. To that end, the Find X7 and Find X7 Ultra are barely more than six months old at this point. H

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

The launch of Samsung's long-awaited 'Special Edition' foldable has taken another twist. In recent weeks, rumours about the so-called Galaxy Z Fold Special Edition went rather quiet. Instead, the focus has shifted to the Galaxy S25 series, including

TheZ9 Turbo+has now been unleashed on Vivo's online Chinese store at 2,199 yuan (~$313) for a 12GB RAM/256GB internal storage base model, whereas theRedmiK70 Extreme Editionstarted at 2,599 yuan (~$370) with the same configuration: in fact, its newiQ
