Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to start local development? #18

Open
mackdunkan opened this issue May 18, 2022 · 7 comments
Open

How to start local development? #18

mackdunkan opened this issue May 18, 2022 · 7 comments

Comments

@mackdunkan
Copy link

Hi!
image

@Viir
Copy link
Member

Viir commented May 20, 2022

If you want to start development with a complete working app as a template, an easy way is to download the contents of this repository and use the example app from implement\example-apps\minimal-backend-hello-world
You can run a server with this command:

elm-fs  run-server  --public-urls="http://*:5000"  --deploy="C:\Users\John\Downloads\elm-fullstack-main\implement\example-apps\minimal-backend-hello-world"

(You can use the Download ZIP button in the GitHub UI to download the repository or use git clone)

image

@mackdunkan
Copy link
Author

Thanks for the answer!
Can I use this for an online store or blog?
I have somewhere around 50 thousand products and about 5 thousand users

@Viir
Copy link
Member

Viir commented May 20, 2022

Yes, it works for online stores and blogs. Fifty thousand items are within the supported limits.

But another metric to consider is the size of your database. At the moment (with the current implementation), the size of the database is limited to a few hundred MB.

For online stores, you often have images taking up quite some space. Usually, the app does not need to read the contents of these images. It is enough to link to them as static external files. Then you can host them outside the Elm app to avoid them blowing up the Elm database size.

@mackdunkan
Copy link
Author

Thanks for the answer
and what aisles the number of elements no longer supports?
What will happen if the database exceeds the limit?
how to deal with SEO for robots, are there any examples?

@Viir
Copy link
Member

Viir commented May 20, 2022

I will run a test to measure the exact limits of today's implementation.
Regarding SEO for robots (crawlers), I recommend https://moz.com/beginners-guide-to-seo/how-search-engines-operate
That article also has many examples.

Viir added a commit that referenced this issue May 27, 2022
Add an example app to support interactive testing of the database limits, as discussed at #18
@Viir
Copy link
Member

Viir commented May 27, 2022

I ran a test and found another important limit for total app state size: App state sizes of more than 166.6 MB will usually crash the server with v2022-03-20.

Therefore elm-fs is not currently fit for that workload.

Restarting a server with v2022-03-20 crashed with this exception:

Application startup exception: System.ArgumentException: The JSON value of length 168831530 is too large and not supported.
   at System.Text.Json.ThrowHelper.ThrowArgumentException_ValueTooLarge(Int32 tokenLength)
   at System.Text.Json.Serialization.Converters.StringConverter.Write(Utf8JsonWriter writer, String value, JsonSerializerOptions options)
   at System.Text.Json.Serialization.JsonConverter`1.TryWrite(Utf8JsonWriter writer, T& value, JsonSerializerOptions options, WriteStack& state)
   at System.Text.Json.Serialization.Metadata.JsonPropertyInfo`1.GetMemberAndWriteJson(Object obj, WriteStack& state, Utf8JsonWriter writer)
   at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryWrite(Utf8JsonWriter writer, T value, JsonSerializerOptions options, WriteStack& state)
   at System.Text.Json.Serialization.JsonConverter`1.TryWrite(Utf8JsonWriter writer, T& value, JsonSerializerOptions options, WriteStack& state)
   at System.Text.Json.Serialization.JsonConverter`1.WriteCore(Utf8JsonWriter writer, T& value, JsonSerializerOptions options, WriteStack& state)
   at System.Text.Json.JsonSerializer.WriteUsingSerializer[TValue](Utf8JsonWriter writer, TValue& value, JsonTypeInfo jsonTypeInfo)
   at System.Text.Json.JsonSerializer.WriteStringUsingSerializer[TValue](TValue& value, JsonTypeInfo jsonTypeInfo)
   at System.Text.Json.JsonSerializer.Serialize[TValue](TValue value, JsonSerializerOptions options)
   at ElmFullstack.WebHost.PersistentProcess.PersistentProcessLiveRepresentation.AttemptProcessEvent(IProcessWithStringInterface process, AppEventStructure appEvent)
   at ElmFullstack.WebHost.PersistentProcess.PersistentProcessLiveRepresentation.RestoreFromCompositionEventSequence(IEnumerable`1 compositionLogRecords, ElmAppInterfaceConfig overrideElmAppInterfaceConfig)
   at ElmFullstack.WebHost.PersistentProcess.PersistentProcessLiveRepresentation.LoadFromStoreAndRestoreProcess(IProcessStoreReader storeReader, Action`1 logger, ElmAppInterfaceConfig overrideElmAppInterfaceConfig)
   at ElmFullstack.WebHost.StartupAdminInterface.<>c__DisplayClass28_0.<Configure>g__startPublicApp|2()
   at ElmFullstack.WebHost.StartupAdminInterface.Configure(IApplicationBuilder app, IWebHostEnvironment env, IHostApplicationLifetime appLifetime, Func`1 getDateTimeOffset, FileStoreForProcessStore processStoreForFileStore)

It crashes because the current implementation depends on a limit similar to the one discussed at: dotnet/runtime#39953

https://github.com/elm-fullstack/elm-fullstack/blob/7ed769b845246ad6adb0ac68c077a6ad250d3f80/implement/elm-fullstack/WebHost/PersistentProcessLiveRepresentation.cs#L249-L251

In our case, it should be MaxCharacterTokenSize:
https://github.com/dotnet/runtime/blob/55e2378d86841ec766ee21d5e504d7724c39b53b/src/libraries/System.Text.Json/src/System/Text/Json/JsonConstants.cs#L77

@mackdunkan
Copy link
Author

Oh thanks for the replies!

Viir added a commit that referenced this issue Mar 24, 2023
Avoid the size limit for the application state discovered at #18: Instead of packaging the JSON in a string, use the JSON directly on the interface to transport to the JS engine.
For further discussion of the serializer limit in System.Text.Json, see dotnet/runtime#39953 and dotnet/runtime#61089
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants