Senior
A service for handling user inquiries A user can send a report Admins can process reports An admin can give feedback to the user DAU = 100 Availability = 99.95% RPS = 100
sobes.tech AI
Answer from AI
For a user request processing service with such requirements (DAU=100, Availability=99.95%, RPS=100), the following architecture and approaches in Go can be proposed:
- API for users:
- Endpoint for creating reports (POST /reports).
- Validation and saving of reports to the database.
- API for admins:
- Retrieving a list of reports with filters and pagination.
- Processing reports (changing status, adding comments).
- Sending feedback to users (e.g., via email or push notifications).
- Technologies:
- Go for backend using frameworks like Gin or Echo.
- Database: PostgreSQL or MongoDB for storing reports.
- Caching (Redis) to speed up reading frequently requested data.
- Ensuring availability (99.95%):
- Horizontal scaling of the service.
- Using health checks and automatic restart.
- Database replication.
- Handling load (RPS=100):
- Go handles high load well thanks to goroutines.
- Use a connection pool to the database.
Example of a simple report creation handler in Go with Gin:
package main
import (
"net/http"
"github.com/gin-gonic/gin"
)
type Report struct {
UserID string `json:"user_id" binding:"required"`
Message string `json:"message" binding:"required"`
}
func createReport(c *gin.Context) {
var report Report
if err := c.ShouldBindJSON(&report); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}
// TODO: save report to DB
c.JSON(http.StatusCreated, gin.H{"status": "report created"})
}
func main() {
r := gin.Default()
r.POST("/reports", createReport)
r.Run(":8080")
}
This service can be extended by adding authentication, authorization, notifications, and analytics.