Building for success and failure with Disqus

37
Building for Success and Failure with AtlantaPHP, October 2014

Transcript of Building for success and failure with Disqus

Page 1: Building for success and failure with Disqus

Building for Success and Failure with

AtlantaPHP, October 2014

Page 2: Building for success and failure with Disqus

Says Every Developer Ever

“Let’s Build a Blog!”

Page 3: Building for success and failure with Disqus
Page 4: Building for success and failure with Disqus
Page 5: Building for success and failure with Disqus

What is it?

• Discussion web service

• Free as in beer

• Integrates with everything

• Quality content

• OAuth and SSO

• Embeddable widget

• Web API

Page 6: Building for success and failure with Disqus
Page 7: Building for success and failure with Disqus
Page 8: Building for success and failure with Disqus
Page 9: Building for success and failure with Disqus
Page 10: Building for success and failure with Disqus

Fundamentals

A crash course

Page 11: Building for success and failure with Disqus

Forum

Thread

Post

Page 12: Building for success and failure with Disqus

Category Limitations

• Categories may only be created using the API.

• Moderation may not be performed on posts by Category, only by Forum and Thread.

Page 13: Building for success and failure with Disqus

Disqus API

threads/createthreads/list

posts/createposts/listposts/report

Full documentation is available at http://disqus.com/api

Page 14: Building for success and failure with Disqus

Registering Your App

https://disqus.com/api/applications/register/

1. Specify Domains

2. Set Permissions

ReadRead and WriteRead, Write, and

Manage

3. Save Tokens

Access TokenAPI KeyAPI Secret

Page 15: Building for success and failure with Disqus

Create a Forum

https://disqus.com/admin/create/

1. Name your site

2. Specify a unique domain

Creating an application does not implicitly create a forum!

Page 16: Building for success and failure with Disqus

Posting to Disqus

As a user

Authenticate via OAuth

As a guest

1. Enable “Allow guests to comment” (Settings > General)

2. Application domain must be set correctly

3. Use the magic API key:

E8Uh5l5fHZ6gD8U3KycjAIAk46f68Zw7C6eW8WSjZvCLXebZ7p0r1yrYDrLilk2F

Page 17: Building for success and failure with Disqus

drexarj/disqus-php github.com/disqus/disqus-phpComposer: drexarj/disqus-php

Page 18: Building for success and failure with Disqus
Page 19: Building for success and failure with Disqus

What could possibly go wrong?

Page 20: Building for success and failure with Disqus
Page 21: Building for success and failure with Disqus
Page 22: Building for success and failure with Disqus
Page 23: Building for success and failure with Disqus

Caching to the Rescue

Page 24: Building for success and failure with Disqus

Caching to the Rescue

Page 25: Building for success and failure with Disqus

It’s Dynamic Data…

• New posts submitted

• Moderator approves post

• Moderator disapproves post

• User flags a post as objectionable

Page 26: Building for success and failure with Disqus

Conflicting Objectives

• High load

• Short cache expiration

• Failover

• No cache expiration

• How to synchronize?

Page 27: Building for success and failure with Disqus

Adding a Failover Cache

burst cache

failover cache

1

23

Page 28: Building for success and failure with Disqus

Failing Over

burst cache

failover cache

1

2

3

Page 29: Building for success and failure with Disqus

Adding a Health Check

burst cache

failover cache

2

4

3

1

Page 30: Building for success and failure with Disqus

Caching Health Status

• If health status expires, everything just fails over

• Adjust the health status expiration to back off:

• FAIL 1: expiration=2 minutes

• FAIL 2: expiration=4 minutes

• FAIL 3: expiration=8 minutes

• …etc

Page 31: Building for success and failure with Disqus

–You

“Is it worth it?”

Page 32: Building for success and failure with Disqus
Page 33: Building for success and failure with Disqus

Implementation: Cache Servers

• Burst: memcached

• Failover: MongoDB (or Redis)

Page 34: Building for success and failure with Disqus

Implementation: Scripts

• Health check

• Cache warmup

• Thread creation

Page 35: Building for success and failure with Disqus

Implementation: API Client

• Guzzle-based client (compwright/disguz)

• Custom Guzzle Cache adapters

Page 36: Building for success and failure with Disqus

Building for Success and Failure with

AtlantaPHP, October 2014

Page 37: Building for success and failure with Disqus

Thank you!

• https://github.com/compwright/disqus-demo

• https://github.com/compwright/disguz

• https://github.com/compwright/disqus-cli

Feedback: https://joind.in/12119