Giter Site home page Giter Site logo

async_request_facebook_attachment_id's Introduction

Upload Facebook Attachment(async)

The current process sends an attachment to user only when user request the file. This causes two problem:

  1. There's a lag time from when user request the file to the time that they receive it (due to the file size)
  2. The same file is being sent multiple times when being requested.
  3. In addition this also solves the problem of transferring files from a bucket to another bucket

Proposed Approach:

  1. Leverage the use of attachment_id by Facebook
  2. Create an additional collection in mongo using URL as a primary key.

Problem Encountered:

  1. There are a few hundread links in our database for each client(each with file size 300KB-15MB), to upload each of them synchronously will take a long time. (IO bound)

Objective:

  1. Convert all links to attachment_id provided by Facebook
  2. Using asynchronous access
  3. Migrate from dev bucket to production bucket

Tools used:

  1. aiohttp
  2. aiofiles
  3. Python

Process Breakdown:

  1. Get all URLs
  2. Filter valid and working URLs
  3. Download all URLs (async)
  4. Upload to new cloud bucket (blocking)
  5. Upload to Facebook for attachment ID (async)
  6. Modify database entries(removing existing attachment_id and update URL)

p/s The program's semaphore is set at 8, can be increased or lowered depending on the network stability

async_request_facebook_attachment_id's People

Contributors

brlala avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.