– Fantasy Stat Tracker …Tracker

A blog about the development of – The Fantasy Baseball Stat Tracker

Posts Tagged ‘architecture’

A quick apology…

Wednesday, April 18th, 2012

As I mentioned yesterday, the old system for generating and sending email boxscores would run up against usage rates on a daily basis, leaving some messages unsent. With the move to SendGrid, our cap is raised, which is a good thing. I removed the limits from What I failed to identify was that all of those unsent email boxscores were still sitting in queue (almost a full year’s worth…). When I removed the limit in and told it to send, boy did it ever!

I logged into SendGrid this morning expecting to see ~470 boxscores sent this morning. Instead the count was nearly 4000! I frantically shut down the process to try to reduce the irritation any more than had already been caused. But a lot of messages went out to people that may not have been expecting them. For that, I am very sorry!

For some reason, these email boxscores have been the single biggest headache with over the years.

Anyway, I’m back in the code tweaking things up in hopes of avoiding another disaster tomorrow.

For all those that have emailed me over the last year about a missed boxscore email, I hope it showed up today! /badjoke

Seriously, though, sorry about the extra messages. I’ll try to make sure it doesn’t happen again.


I’ve made three changes to try to avoid this happening again:

1) I’ve cleared the email queue so nothing old even exists now.

2) I’ve capped the number of email boxscores will send tomorrow at 500. This is slightly higher than the number I think should be sent, so hopefully everyone gets their proper messages. If something goes wrong, though, the impact will be minimal.

3) I’ve updated the script that selects the emails to send to have it double-check that it is only pulling email boxscores generated in the current day.

Hopefully these three actions will prevent this from happening tomorrow. Nonetheless, I’ll be keeping a very close eye on things in the morning.

Moving to SendGrid

Monday, April 16th, 2012

In the next day or so will be moving its email handling to SendGrid. This should give me better transparency into what messages are being send, received, and bounced back. Right now things are a bit of a manual process which makes it difficult to diagnose one-off errors (particularly with daily boxscore emails).

If all goes well, I’ll probably make the change tonight. Theoretically, there should be no change for anyone but me. Let’s hope it works out that way!

I love Kilgus! Can you include [STATX]?

Friday, April 6th, 2012

This is by far the most common topic when people email me about I’m thrilled that so many people are enjoying the tool (we start the year with over 1800 members, nearly 500 users per day), but these are bummer emails to receive.

Unfortunately, 95% of the time the answer: No, sorry.

As a free tool, needs to rely on whatever free stats we can find. As it turns out, MLB publishes some limited live data (I believe for their GameDay feature) that we’ve been able to tap. While it is great that the data is free, the bummer is that it isn’t comprehensive. is already pulling every stat available from MLB and even calculating a whole series more that aren’t made available in the data feed.

If you’re favorite stat isn’t included, it’s almost certainly because we just don’t have access to it. At the start of each season, I double-check the feeds to see if any new stats are available. This year, there is nothing new.

So, if there is something that can be calculated with the data already in, let me know and I’ll be happy to add it! If you want a new counting stat added, though, I can’t add it.

Maybe someday an angel investor will throw a pile of money at and we can afford to purchase a real data feed (~$25k/year). Until then, we just have to make due with what we have.

Hopefully it’s enough to be useful to you!

(That said, don’t forget to click “Select Stats” for each of your teams to see all the stats that are available: currently 32 categories!)

Migration Success!

Tuesday, May 3rd, 2011

I’m a little tepid to call the migration a success, but things seem to have worked. The site, blog, databases, scheduled processes, accounts, teams, stats…they’re all moved over. And as best I can tell, they are all working. I’ll be keeping a very close eye on things through the week in case anything goes awry, but we seem to be in good shape for now. If you notice any odd behavior, errors, or encounter problems PLEASE comment here, post to Facebook or Twitter, or send me an email so I can get to the root of things.

Now that the migration is complete, I’ll also finally get to some upgrades! First on the list are some new statistical categories. Please keep in mind that uses a free data source from MLB that only offers limited information. I pull as much out of that source as I can, but some stats just aren’t available. Also on the list is some tweaking to the sign-up/log-in form. I have been receiving quite a few emails about issues with it, most specifically with Internet Explorer 8. If you encounter problem signing-up or logging-in in the meantime, try a browser other than IE8.

Just for fun: now manages over 2300 teams for more than 1300 users! And with the new hosting infrastructure, my testing is showing 3-4 second rendering times for team stat pages compared to 13-23 seconds at the old host. Light speed!

I hope you all continue to enjoy using Our new hosting should make your stat tracking experience faster and better than ever!

Cross your fingers!

Friday, April 15th, 2011

Tomorrow morning will use a entirely new process for generating and sending daily boxscore emails! So let’s all cross our fingers and hope it works…

I have spent all of this week re-designing and re-building how emails are generated, stored, and sent. Suffice to say, the new system is significantly more complex than the old one. When I’ve had a chance to breath and am not so tired, I’ll go into more detail on how it works.

My expectations of the new system are that it will:

  • Scale to accommodate as many users/emails as desired (the old system failed in the 200-300 range)
  • Allow of future portability if needs to change hosting
  • Implement all components to identify HTML vs. Text email so boxscores render properly on all clients
  • Allow for side-by-side HTML and Text versions (text version is forthcoming)
  • Provide redundancy of data, so if the process fails it can be re-started without losing a day’s data
  • Reduce likelihood of mail servers being identified as SPAM and black-listed
  • Lower computation overhead

It sounds almost too good to be true! Tomorrow’s push will be the first full run trying to send out to everyone’s unique addresses. All the testing so far has been delivering to a address (or small tests to outside domains). I’ll be keeping an eye on things in the morning to try to ensure everything goes smoothly. If you do not receive your normal boxscore in an acceptably legible format, please post comments here with details (DETAILS–without them I can’t do anything–what email client, what team name, what was wrong, screenshots, any little detail).

Quick Update on Emails

Thursday, April 14th, 2011

I’ve been frantically working away on a new email system for the last couple days. The goal is to streamline the process, reduce execution time, reduce likelihood for failure, and improve the quality of the email delivered to your inbox. I’m about 20 hours into the effort, but spent 6 hours going in circles last night…very frustrating. As is often the case, I slept on it and have some new ideas this morning, so I’m again optimistic that I’ll be rolling it out in the coming days. Check back for updates.

In the mean time, a number of people have been reporting that their emails are not being displayed as HTML in their email clients. I haven’t tried to troubleshoot this as I am replacing the system anyway. If you are experiencing this, it wouldn’t hurt to comment with what email client you use (Thunderbird, Outlook, Gmail, iPhone Mail, etc.). We might notice a pattern and be able to share some advice with one another.

As far as I know, emails have gone out properly for three straight days now. If you’re not seeing them, leave a comment, ping me on twitter (@kilgustracker), or shoot me an email (

Why it went wrong

Monday, April 11th, 2011

As many of you experienced, this morning the daily boxscores went horribly wrong and began sending piles of duplicate mails to everyone. If I haven’t apologized to you yet: I’m sorry. I try very hard to make sure any changes I make to won’t have an adverse effect on users. I bungled this one, but at least I think I’ve figured out what happened.

I mentioned previously that I moved the daily boxscore email script to the new server. That is why emails went out to anyone. On the new server PHP is installed differently from the old server. As a result, when I run the CRON job to generate the emails, I needed to use an application to call the script rather than just calling PHP to execute it. I chose to use a program called wget. The idea is that wget makes a call to a URL and that URL (a PHP file) generates and sends the emails. Before scheduling the morning’s emails, I tested to ensure the process worked. When I tested, though, I only used a sub-set of data. I didn’t really need 350 emails coming into my inbox, so I tested with a couple emails each for those sent to a team owner and those sent to a team viewer. That worked great.

When the CRON job ran this morning, everything seemed to go well until duplicates started showing up. A second round, then a third, then a fourth and so on. Interestingly, each wave was 15 minutes apart. As it turns out, if wget can’t complete a request (in this case a VERY long request for 350 emails), it tries again. By default it will try up to 20 times to fetch a file. Because the script takes so long to run, I believe it exceeded the server time-out.  When the script timed out, wget requested it a second time, then a third, then a fourth and so on. I believe this is what caused the duplicate emails.

I’ve made three adjustments to address this. First, I increased the server time-out for this process. Second, I have changed the CRON job to tell wget never to retry the fetch if it fails. Third, I’ve broken the massive emails process into multiple chunks. This is a temporary fix until I convert to using PEAR::Mail to more intelligently manage the process. I’m done for tonight, but that will probably be the priority tomorrow.

So that’s all of today’s work. Six hours sunk, but I think the emails will work in the morning. I’ve pushed back the time that the emails go out by a couple hours to they’ll line up with when I roll out of bed in the morning. If things go off-track, I’ll be able to curtail things faster than today. If all goes well, I’ll move the schedule back to the early morning hour so everyone has the boxscore email when they get up in the morning.

Keep your fingers crossed…


Season-to-Date Stats

Saturday, April 3rd, 2010

This evening I completed work to allow Owners to track their teams’ season-to-date statistics. This has been a popular request throughout the past year.  Your team’s season-to-date stats are now available from each Team page by clicking on the “Season-to-Date” tab just below your team name. Clicking the “Today” tab will return you to your live, up-to-the-minute daily stats.

Season-to-Date statistics are for the players CURRENTLY on your roster. does not track the changes you make to your roster throughout the season. The Season-to-Date statistics center around a Strat-O-Matic scoring model. I’ve never played Strat-O-Matic, but–as described to me–roster moves aren’t allowed during the season. Rosters are locked in before the season and only change in the off-season.

For those playing in a standard fantasy baseball league, these Season-to-Date stats will be different than your fantasy team’s total stats (accumulating stats for players in your lineup on any given day). For Owners in this situation, season-to-date stats will make it a touch easier to view all your players’ season performance, but won’t be of direct use when tracking your team’s performance.

Adding Season-to-Date stats wasn’t a trivial matter. I had to make changes to more than a half-dozen of’ most important objects. In addition to changes to objects, the database was also expanded to include tables to store the season stats for players. At the moment, the objects are writing to the database via SQL statements. In the coming days I’ll update to use stored procedures like the rest of the database communications.

I have tried to test for unexpected repercussions from the object and database changes, but please let me know if you encounter any odd behavior by posting a comment or emailing me.

Email Box Score Issue

Thursday, March 18th, 2010

Looks like last night’s 2010 re-launch wasn’t spotless–the script to generate and send email box scores didn’t run correctly this morning. Part of the new 2010 efforts included re-structuring the organization of classes in the file system to follow more standard practices. It looks like the script in question was missing a reference to the class it needed to determine the date for which it should be sending the box scores.

I’ve updated the script and expect it to run tomorrow without a hitch. I don’t intend to run the script to generate box score emails today because it is still spring training. If you have an urgent and dire need for a box score email, let me know and I’ll see what can be done.

2010 Launch

Tuesday, March 16th, 2010

Tomorrow (3/17) evening I plan to launch the 2010 updates for Launch will probably commence around 10pm Mountain time. The launch will replace the entire code base with a new iteration. This will likely result in at least a few minutes–and as much as a few hours–of downtime.

I will blog and tweet (@kilgusTracker) updates to announce when the launch is completed.

In addition to the updates, I will be publishing a series of blog posts to describe the changes and how to use the new features of For current users, you will find the interaction mechanisms to be very familiar. A new visual style is the most disruptive change. As the season progresses I’ll be getting back to refining the functionality of the tool