Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

LaraDeveloper's avatar

MySQL challenges when handling web analytics service

Hi everyone,

We have a web analytics service (measuring website traffic) running on one Laravel job.

We are seeing these issues:

  1. Duplicate entries

Ex: 2 entries right after each other, exact same created_at date

This seems to be happening because of 2 hits from the same visitor arrive quickly, while the first hit process is still being recorded.

  1. Missing data

We have functions that attach user IDs to certain hits after they have identified themselves.

For some reason sometimes the update query that's supposed to attach the user ID does not run.

The query is being done using Eloquent model (find, update, save)

  1. MySQL status reports a lot of issues:
  • Aborted clients
  • Aborted connections

Even after increasing the max MySQL connections from 150 to 5000, it's still showing aborted clients and connections which keeps increasing every minute.

This should be related to the missing data issue.

Not sure where to start to improve on this and make it work with 0 issues.

Thank you

0 likes
3 replies
Tray2's avatar

For the duplicates you can always check first if a record exists with that combined key and if it does do nothing. I take it you are using timestamps for this and I highly doubt they are exactly the same.

For the connection issues it sounds to me that somewhere in your code you are either using persistant connections or the connection isn't properly closed,

All of this is very hard to help you with since it's using a pellet gun in the ocean hoping to hit a cod.

Provide the code for both these issues and it will be easier for us to help.

1 like
MenorTayn's avatar

For duplicate entries, you might want to consider a locking mechanism or database transactions. And for missing data, maybe review your query logic. As for MySQL issues, check server resources and slow queries. Also, here is a web analytics dashboard template to help you arrange information. Good luck!

Please or to participate in this conversation.