Developing a Social Network Mobile App
A social network is one of the most technically demanding mobile app types. Feed with algorithmic sorting, real-time notifications, media upload, people search, relationship graph—each requires a separate thoughtful approach. Scaling that works at 1000 users breaks at 100,000.
Content Feed: The Main Architectural Question
Feed in Instagram, TikTok, Twitter—not just "query DB, sort by date." It's personalized ranking based on relationship graph, interaction history, and engagement signals.
At start—chronological feed with cursor-based pagination: GET /feed?cursor=<timestamp>&limit=20. Cursor-based over offset—because new posts shift offsets. Cursor is encoded created_at + id.
Algorithmic feed—harder: ranking based on weights (publication time, likes in first N minutes, author engagement, graph proximity). Early stage—simple heuristics computed on backend, cached in Redis. Full ML ranking—separate project.
Fan-out strategy. When a user with 50k followers posts—can't write 50k rows to feed tables synchronously. Standard: fan-out on write (queue job for each follower via message queue—Kafka/RabbitMQ), fan-out on read (form feed on request from followings' posts). Hybrid: regular users—fan-out on write, celebrities—on read.
Real-Time: Notifications and Activity
Real-time updates needed: like on post, new follower, comment reply. Approaches:
- Long polling—outdated, creates excess load.
-
WebSocket—right for chat and real-time activity. iOS:
URLSessionWebSocketTask, Android: OkHttpWebSocket. Problem: mobile devices kill background connections. -
Firebase Realtime Database / Firestore—ready solution with offline persistence. Firestore
addSnapshotListener—live updates out of the box. Good for MVP, requires rethink at scale. - Push + local state merge. FCM/APNs wake-up, app on startup requests change delta. Most battery-friendly for mobile.
Relationship Graph and People Search
"Who follows whom" graph—poorly mapped in relational DB at millions of users. MVP: follows (follower_id, following_id) table in PostgreSQL with indexes—works to hundreds of thousands. At growth—graph DB (Neo4j) or specialized solutions.
People search by name: Elasticsearch with match_phrase_prefix for autocomplete, edge_ngrams for partial match. Phonetic search—phonetic analyzer for fuzzy name matching.
"Follow suggestions" at start: mutual followers, same region/contacts (ContactsFramework iOS, ContactsContract Android—with explicit user permission).
Media: Upload and Processing
Upload photo/video—always multipart with presigned URL to S3/object storage. Never through backend as proxy: unnecessary server load. Client gets presigned URL → uploads directly to storage → confirms to backend.
Video processing: transcoding to multiple qualities (360p, 720p, 1080p) via AWS MediaConvert, Cloudflare Stream, or self-hosted FFmpeg. Thumbnail from first frame. HLS output for adaptive streaming.
On mobile before upload—compress: UIGraphicsImageRenderer for photos (target size + JPEG quality), AVAssetExportSession with AVAssetExportPresetMediumQuality for video. Without this, iPhone Pro Max users upload 50+ MB per post.
Content Moderation
Auto-moderation—mandatory from day one: Google Cloud Vision Safe Search, AWS Rekognition, or PhotoDNA for CSAM detection. User text—classification models via OpenAI Moderation API or open-source (Google's Perspective API).
On iOS: PHPhotoLibrary permission readWrite when uploading from gallery, Android—READ_MEDIA_IMAGES / READ_MEDIA_VIDEO (Android 13+).
Privacy and Compliance
GDPR: right to deletion, data export. Technical: soft delete with flag + scheduled job for physical deletion after 30 days. Media archived to cold storage.
Timelines
MVP with feed, profiles, follows, likes: 8–12 weeks. Full social network with media, search, stories, moderation: 4–8 months. Cost calculated individually after analyzing requirements.







