消费社交网络的架构问题休息服务?

发布于 2024-10-06 16:04:36 字数 336 浏览 2 评论 0原文

我必须集成 Facebook 等社交网络来显示用户朋友已阅读、点击或评论的项目。出现一些架构问题:

问题: a)我应该在我的应用程序数据库中缓存用户的好友列表吗?缺点是用户好友列表可能会发生变化。或者我应该在每次登录后获取此列表?

b) 当用户登录我的应用程序(使用 oauth)时,获取他/她的朋友列表的最佳方式是什么——我应该在 Web 请求线程中执行此操作,这是我在本地数据库中创建位置的地方,或者我应该生成一个不同的任务/线程/批处理作业来获取此列表?

c) 用户缩略图:如果用户登录,我应该缓存用户个人资料缩略图并从我的应用程序中提供它,还是应该在页面上嵌入个人资料图片 URL(指向社交网站)?

I have to integrate Social Networks such as Facebook etc. to display items that have been read or clicked or commented by users' friends. Some architecture questions arise :

questions :
a) should I cache the user's friend list in my app db ? The downside is that the list of users friends could change. Or should I fetch this list after every login ?

b) When a user logs in to my app ( using oauth) , what is the best way to fetch his/her friends list -- should I do that in the web request thread, which is where I am making locs to our local db, or should I spawn a different task / thread/ batch job to fetch this list ?

c) user thumbnail images : if a user logs in , should I cache the user profile thumbnail picture and serve it from my app or should I just embed the profile pic url ( pointing to the social site) on the page?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

°如果伤别离去 2024-10-13 16:04:36

我以前从未与社交网络(SN)集成过,所以我的建议是一般性的(抱歉)。

A) 缓存

  • 您希望您的系统有什么用途?如果目标 SN 对您的应用程序在给定时间段内可以发出的请求数量有限制,这一点很重要。假设的示例:如果您每小时要进行 100 次登录,但 SN 将您每小时的请求数限制为 50 次,那么您将必须进行缓存。也许是个坏例子,但我相信你明白了。
  • 数据多久更改一次?如果数据有误,人们会在多大程度上关心这些数据?如果您可以获得一组与人们的朋友更换频率大致一致的新数据,那么您将在保持准确性的同时尽可能高效。
  • 在获取新的设置之前,您可以查询 SN 以查看数据是否已更改吗?
  • 如果您遇到与获取数据相关的性能问题,那么您需要考虑缓存。

B) OAuth

如果您可以异步执行,那么这可能不是一个坏主意。您无法控制目标系统,那么当事情进展不顺利时您该怎么办?您可能希望使其尽可能简单;除了使用 AJAX 之外,我对异步工作了解不多(但这听起来像是您在后端?),所以我不确定具体细节。

C) 缩略图

  • 查看目标SN的回链政策;如果他们允许,那么这是一种选择,否则...
  • 如果您从中提取映像的 SN 是主要的,那么他们的系统可能会比您的系统具有更高的可用性。这表明链接到它们不会成为可能下降并使您的应用程序看起来很糟糕的依赖项。或者,如果怀疑它们的可用性,您可以通过将所有内容放在一起来提供一致的应用程序。
  • 如果您的托管计划有带宽限制或与带宽相关的费用,您可以通过链接节省 $$;但这正是您的目标 SN 可能不允许它的原因。
  • 如果目标 SN 决定改变策略(并切断您的链接) - 您怎么知道?
  • 顺便说一句,StackOverflow 采用了链接方法,但目标是专门为实现这一点而构建的基于云的服务(据我所知)。

I've never integrated with Social Networks (SN) before so my advice is going to be general (sorry).

A) Caching

  • What sort of use of your system are you expecting? This is important if the target SN has a limit on how many requests your app can make in a given time period. Hypothetical example: if you're going to get 100 logins an hour but the SN limits you to 50 requests an hour then you're going to have to cache. Bad example perhaops but I'm sure you get the idea.
  • How often does the data change, and how much do people care if it's wrong? If you can get a fresh set of data roughly in-line with how often people's friends change then you'll be as efficient as you can be whilst preserving accuracy.
  • Can you query the SN to see if the data has changed before getting a new set back?
  • If you run into performance issues related to getting the data then you'd want to consider caching.

B) OAuth

If you can do it asynchronously then it's probably not a bad idea. You have no control over the target system, so what do you do when things don't go well? You'd probably want to make this as simple as possible; I don't know much about working asynchronously except using AJAX (but this sounds like you're in the back-end?), so I'm not sure of specifics.

C) Thumbnails

  • Check the target SN's policy on linking back; if they allow it then it's an option, otherwise...
  • If the SN you're pulling the image from is a major one it's likely their systems are going to be more highly available than yours. This would suggest linking to them isn't going to be a dependency that's likely to go down and make your app look bad. Alternatively, if their availability is suspect you'll offer a consistent app by keeping everything together.
  • If your hosting plan has bandwidth restrictions or bandwidth related costs you'll save $$ by linking; but this is exactly why your target SN might disallow it.
  • If the target SN decides to change policy (and cuts off your links) - how will you know?
  • Incidently, StackOverflow takes a linking approach, but is targeting a cloud based service that is built specifically to allow that (as far as I am aware).
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文